Skip to content

Commit 7624a47

Browse files
committed
Merge pull request #10 from ryagin/master
Fix #9: use URL encoding for encoding file names
2 parents 548741e + 4e415c2 commit 7624a47

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@
4040

4141
* `change`: Typical change event. Triggered when a file is selected.
4242

43-
* `Files.prototype.$save.call()`: Treats the file object as an instance of `$resource`, and POSTs the raw contents of the file to the configured URL. The upload handler also sets four headers: `X-File-Name`, `X-File-Size`, `X-File-Last-Modified`, and `Content-Type`.
43+
* `Files.prototype.$save.call()`: Treats the file object as an instance of `$resource`, and POSTs the raw contents of the file to the configured URL. The upload handler also sets four headers: `X-File-Name`, `X-File-Size`, `X-File-Last-Modified`, and `Content-Type`.
44+
45+
The `X-File-Name` header is encoded with URL encoding.

src/angular-file.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ angular.module('ur.file', []).config(['$provide', function($provide) {
6868
}
6969

7070
if (angular.isObject(post)) {
71+
if (post && post.name && !headers['X-File-Name']) {
72+
headers['X-File-Name'] = encodeURI(post.name);
73+
}
74+
7175
angular.forEach({
72-
name: 'X-File-Name',
7376
size: 'X-File-Size',
7477
lastModifiedDate: 'X-File-Last-Modified'
7578
}, function(header, key) {

0 commit comments

Comments
 (0)