【发布时间】:2017-10-20 15:48:33
【问题描述】:
我使用 angular-file-upload 模块在我的 Angular 应用程序中上传文件,但我有要求再次上传相同的文件,但无法再次上传,因为模块在上传之前检查 item(file) 的 isUploaded 属性. 有什么解决办法吗
【问题讨论】:
-
请向我们展示您的代码
标签: angularjs file-upload angular-file-upload
我使用 angular-file-upload 模块在我的 Angular 应用程序中上传文件,但我有要求再次上传相同的文件,但无法再次上传,因为模块在上传之前检查 item(file) 的 isUploaded 属性. 有什么解决办法吗
【问题讨论】:
标签: angularjs file-upload angular-file-upload
我们可以使用onAfterAddingFile 在将文件添加到队列后触发的回调来存储原始文件的副本。现在我们可以使用uploader1和uploader2分别上传原始文件和复制文件:
$scope.uploader1 = new FileUploader({
url: url,
queueLimit: 1
});
$scope.uploader2 = new FileUploader({
url: url,
queueLimit: 1
});
uploader1.onAfterAddingFile = function (fileItem1) {
var fileItem2 = new FileUploader.FileItem($scope.uploaderOnSuccess,
{
lastModifiedDate: fileItem1.file.lastModifiedDate,
size: fileItem1.file.size,
type: fileItem1.file.type,
name: fileItem1.file.name,
});
fileItem2._file = fileItem1._file;
fileItem2.progress = 0;
fileItem2.isUploaded = false;
fileItem2.isSuccess = false;
$scope.uploader2.queue.push(fileItem2);
};
【讨论】: