Skip to content

Commit d0a82f9

Browse files
committed
fix
1 parent 1e4a1d6 commit d0a82f9

File tree

3 files changed

+66
-5
lines changed

3 files changed

+66
-5
lines changed

README.md

+62-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,65 @@
11
angularQFileUpload
22
==================
33

4-
AngularJS qiniu cloud storage large file upload service with support resumble,progress
4+
AngularJS qiniu cloud storage large file upload service with support resumble,progress based on html5 file blob reader
5+
6+
**Only woking under html5**
7+
8+
## Install
9+
10+
```
11+
bower install angular-qiniu-upload
12+
```
13+
14+
## Usage
15+
16+
- Add 'angularQFileUpload' to your main module's list of dependencies.
17+
18+
```
19+
<script>
20+
var myApp = angular.module('myApp', ['angularQFileUpload']);
21+
</script>
22+
```
23+
24+
- Upload file
25+
26+
```
27+
$scope.selectFiles = [];
28+
29+
var start = function (index) {
30+
$scope.selectFiles[index].progress = {
31+
p: 0
32+
};
33+
$scope.selectFiles[index].upload = $qupload.upload({
34+
key: '<your qiniu file key>',
35+
file: $scope.selectFiles[index].file,
36+
token: '<your qiniu UpToken>'
37+
});
38+
$scope.selectFiles[index].upload.then(function (response) {
39+
// upload success
40+
$log.info(response);
41+
}, function (response) {
42+
// upload failure
43+
$log.info(response);
44+
}, function (evt) {
45+
// progress
46+
$scope.selectFiles[index].progress.p = Math.floor(100 * evt.loaded / evt.totalSize);
47+
});
48+
};
49+
50+
$scope.abort = function (index) {
51+
$scope.selectFiles[index].upload.abort();
52+
$scope.selectFiles.splice(index, 1);
53+
};
54+
55+
$scope.onFileSelect = function ($files) {
56+
var offsetx = $scope.selectFiles.length;
57+
for (var i = 0; i < $files.length; i++) {
58+
$scope.selectFiles[i + offsetx] = {
59+
file: $files[i]
60+
};
61+
start(i + offsetx);
62+
}
63+
};
64+
```
65+
-- reference, [http://developer.qiniu.com/docs/v6/api/reference/up/](http://developer.qiniu.com/docs/v6/api/reference/up/)

bower.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-qiniu-upload",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"homepage": "https://github.com/icattlecoder/angularQFileUpload/blob/master/README.md",
55
"authors": [
66
"icattlecoder <icattlecoder@gmail.com>"
@@ -24,10 +24,10 @@
2424
],
2525
"dependencies": {
2626
"angularjs": "~1.2.16",
27-
"angular-local-storage": ">0.1.4"
27+
"angular-local-storage": "0.1.4"
2828
},
2929
"devDependencies": {
3030
"angularjs": "*",
3131
"angular-local-storage": ">0.1.4"
3232
}
33-
}
33+
}

demo/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div ng-file-select="onFileSelect($files)" data-multiple="true" title="select file" onclick="this.value = null" class="btn btn-upload">Click here to select file</div>
1818
<ol>
1919
<li ng-repeat="(k,v) in selectFiles">
20-
{{v.file.name}} - {{v.progress.p}} <button ng-click="abort(k)">xx</button>
20+
{{v.file.name}} - {{v.progress.p}}% <button ng-click="abort(k)">x</button>
2121
</li>
2222
</ol>
2323
</div>

0 commit comments

Comments
 (0)