// Generated by CoffeeScript 1.12.7
/**
* Upload file
* @namespace uploadService
*/
'use strict';
app.factory('uploadService', [
'$q', '$sce', 'constantService', 'routerService', 'messageService', function($q, $sce, constants, router, messages) {
return {
removedAsset: void 0,
flowOptions: function() {
return {
target: router.controllers.uploadChunk.route(),
method: 'octet',
chunkSize: 1048576,
forceChunkSize: true,
simultaneousUploads: 3,
testChunks: false,
chunkRetryInterval: 5000,
permanentErrors: [400, 403, 404, 409, 415, 500, 501],
successStatuses: [200, 201, 202, 204],
progressCallbacksInterval: 500,
prioritizeFirstAndLastChunk: false,
headers: {
'x-csverf': router.http.csverf
}
};
},
upload: function(volume, file) {
file.pause();
return router.http(router.controllers.uploadStart, volume.id, {
filename: file.name,
size: file.size
}).then(function(res) {
file.uniqueIdentifier = res.data;
file.resume();
}, function(res) {
messages.addError({
type: 'red',
body: constants.message('asset.upload.rejected', {
sce: $sce.HTML
}, file.name.substr(file.name.lastIndexOf('.') + 1)),
report: res
});
file.cancel();
return $q.reject(res);
});
}
};
}
]);
//# sourceMappingURL=upload.js.map