-
-
Notifications
You must be signed in to change notification settings - Fork 166
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 #744 from VeliovGroup/dev
v1.14.2 - 🐞 Fix #742, thanks to @menelike and @jankapunkt - 🤓 Update *TypeScript* definitions, thanks to @OliverColeman PR #743, see #226 thread for details - 🤝 Compatibility with `[email protected]` - 📋 Documentation update to address issue described in #737, thanks to @menelike, @Lickshotz, @s-ol, and @jankapunkt
- Loading branch information
Showing
9 changed files
with
1,592 additions
and
403 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ [email protected] | |
[email protected] | ||
[email protected] | ||
[email protected] | ||
local-test:ostrio:[email protected].1 | ||
local-test:ostrio:[email protected].2 | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
|
@@ -36,7 +36,7 @@ [email protected] | |
[email protected] | ||
[email protected] | ||
ostrio:[email protected] | ||
ostrio:[email protected].1 | ||
ostrio:[email protected].2 | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
|
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,67 @@ | ||
Please refer to [`docs/custom-response-headers.md`](https://github.com/VeliovGroup/Meteor-Files/blob/master/docs/custom-response-headers.md). | ||
# Custom Response Headers | ||
|
||
- `config.responseHeaders` option (*passed into [`FilesCollection` 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 | ||
|
||
```js | ||
function responseHeaders (responseCode, fileRef, versionRef) { | ||
const headers = {}; | ||
switch (responseCode) { | ||
case '206': | ||
headers['Pragma'] = 'private'; | ||
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__. | ||
|
||
```js | ||
// As function (keep original function with additions): | ||
const Uploads = new FilesCollection({ | ||
responseHeaders(responseCode, fileRef, versionRef, version, http) { | ||
const headers = {}; | ||
switch (responseCode) { | ||
case '206': | ||
headers['Pragma'] = 'private'; | ||
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): | ||
const Uploads = new FilesCollection({ | ||
responseHeaders: { | ||
Connection: 'keep-alive', | ||
'Access-Control-Allow-Origin': '*' | ||
} | ||
}); | ||
``` |
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
Oops, something went wrong.