-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from VeliovGroup/dev
v1.6.3 - Compatibility with [email protected] - Update NPM dependency for `request` package to `2.73.0` - Implement #141
- Loading branch information
Showing
9 changed files
with
578 additions
and
596 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
dev_bundle | ||
local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[email protected].1 | ||
[email protected].4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#### `FilesCollection` `config.responseHeaders` option (*passed into [Constructor](https://github.com/VeliovGroup/Meteor-Files/wiki/Constructor)*) | ||
Allows to change default response headers. | ||
|
||
##### Default function: | ||
We recommend to keep original function structure, with your modifications | ||
```javascript | ||
function responseHeaders (responseCode, fileRef, versionRef) { | ||
var headers = {}; | ||
switch (responseCode) { | ||
case '206': | ||
headers['Pragma'] = 'private'; | ||
headers['Trailer'] = 'expires'; | ||
headers['Transfer-Encoding'] = 'chunked'; | ||
break; | ||
case '400': | ||
headers['Cache-Control'] = 'no-cache'; | ||
break; | ||
case '416': | ||
headers['Content-Range'] = "bytes */" + versionRef.size; | ||
} | ||
headers['Connection'] = 'keep-alive'; | ||
headers['Content-Type'] = versionRef.type || 'application/octet-stream'; | ||
headers['Accept-Ranges'] = 'bytes'; | ||
return headers; | ||
}; | ||
``` | ||
|
||
##### Adding custom header example: | ||
We recommend to pass `responseHeaders` as a <em>Function</em>, response headers __should be conditional__ | ||
```javascript | ||
// As function (keep original function with additions): | ||
var Uploads = new FilesCollection({ | ||
responseHeaders: function(responseCode, fileRef, versionRef, version) { | ||
var headers = {}; | ||
switch (responseCode) { | ||
case '206': | ||
headers['Pragma'] = 'private'; | ||
headers['Trailer'] = 'expires'; | ||
headers['Transfer-Encoding'] = 'chunked'; | ||
break; | ||
case '400': | ||
headers['Cache-Control'] = 'no-cache'; | ||
break; | ||
case '416': | ||
headers['Content-Range'] = "bytes */" + versionRef.size; | ||
} | ||
headers['Connection'] = 'keep-alive'; | ||
headers['Content-Type'] = versionRef.type || 'application/octet-stream'; | ||
headers['Accept-Ranges'] = 'bytes'; | ||
headers['Access-Control-Allow-Origin'] = '*';// <-- Custom header | ||
return headers; | ||
} | ||
}); | ||
|
||
// As object (not recommended): | ||
var Uploads = new FilesCollection({ | ||
responseHeaders: { | ||
Connection: 'keep-alive', | ||
'Access-Control-Allow-Origin': '*' | ||
} | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.