AngularJS 大文件上傳:angularQFileUpload
angularQFileUpload 是一個 AngularJS 擴展,實現了通過七牛云儲存上傳大文件的服務,支持恢復、進度等功能。
示例代碼:
$scope.selectFiles = []; var start = function (index) { $scope.selectFiles[index].progress = { p: 0 }; $scope.selectFiles[index].upload = $qupload.upload({ key: '<your qiniu file key>', file: $scope.selectFiles[index].file, token: '<your qiniu UpToken>' }); $scope.selectFiles[index].upload.then(function (response) { // upload success $log.info(response); }, function (response) { // upload failure $log.info(response); }, function (evt) { // progress $scope.selectFiles[index].progress.p = Math.floor(100 * evt.loaded / evt.totalSize); }); }; $scope.abort = function (index) { $scope.selectFiles[index].upload.abort(); $scope.selectFiles.splice(index, 1); }; $scope.onFileSelect = function ($files) { var offsetx = $scope.selectFiles.length; for (var i = 0; i < $files.length; i++) { $scope.selectFiles[i + offsetx] = { file: $files[i] }; start(i + offsetx); } };
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!