skipper-proxy
v1.1.2
Published
Skipper adapter to proxy the upstream to a remote server
Downloads
4
Maintainers
Readme
Skipper Proxy Adapter
Proxy upload stream to another server using skipper and got
If you want to proxy upload stream to other server on fly using Skipper, this is the Skipper adapter for you.
Things you can do with Skipper-Proxy
adater
- Proxy upload stream without writing a file to a server.
[Browser]--(File Upload)-->[Server 1]--(Proxy File Upload)-->[Server 2] - Change the request method (PUT, POST, PATCH, HEAD) & form field name when proxy to the remote server.
- Add additional headers to the upload streams
From the proxy server, you can treat the upload stream as if the upload is directly from a browser.
Installation
$ npm install skipper-proxy --save
Also make sure you have skipper installed as your body parser.
Skipper is installed by default in Sails v0.10 and above.
Usage
req.file('file') // <-- the fieldname from a browser upload
.upload({
adapter: require('skipper-proxy'),
url: 'https://example.com', // REQUIRED: Proxy server URL
method: 'put', // OPTIONAL: Default = 'put'
maxBytes: 1000 * 1000 * 5, // OPTIONAL: Maximum bytes to upload
fieldName: 'file', // OPTIONAL: Form data field name for the proxy server. Default = 'file'
retries: 2, // OPTIONAL: Number of request retries on failure. Defeault = 2
headers: { <key> : <value> } // OPTIONAL: Request headers to the proxy server
}, function whenDone(err, uploadedFiles) {
if (err) {
return res.negotiate(err);
}
else {
return res.ok({
files: uploadedFiles
});
}
});
| Option | Type | Details |
|----------- |:----------:|---------|
| url
| ((string)) | A REQUIRED
parameter of the host or domain/IP.|
| method
| ((string)) | An optional parameter for request method. Default value : 'put'
|
| maxBytes
| ((number)) | An optional parameter for maximum bytes to upload.|
| fieldName
| ((string)) | An optional parameter for proxy form data field name. Default value :'file'
|
| retries
| ((number)) | An optional parameter for number of request retries on failure. Default value : 2
|
| headers
| ((object)) | An optional parameter for header objects|
License
MIT License (MIT)