Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnkimdev/skipper-proxy
Proxy skipper's upstream to other server
https://github.com/johnkimdev/skipper-proxy
Last synced: about 2 months ago
JSON representation
Proxy skipper's upstream to other server
- Host: GitHub
- URL: https://github.com/johnkimdev/skipper-proxy
- Owner: JohnKimDev
- License: mit
- Created: 2019-01-04T06:01:47.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-10T12:54:49.000Z (about 6 years ago)
- Last Synced: 2023-12-22T21:09:14.698Z (about 1 year ago)
- Language: JavaScript
- Size: 3.34 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# [](https://github.com/JohnKimDev/skipper-proxy) Skipper Proxy Adapter
[![npm](https://img.shields.io/npm/v/skipper-proxy.svg)](https://www.npmjs.com/package/skipper-proxy)
[![npm](https://img.shields.io/npm/l/express.svg)]()Proxy upload stream to another server using [skipper](https://github.com/balderdashy/skipper) and [got](https://github.com/sindresorhus/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 streamsFrom 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](http://beta.sailsjs.org/#/documentation/concepts/Middleware?q=adding-or-overriding-http-middleware).
> Skipper is installed by default in [Sails](https://github.com/balderdashy/sails) v0.10 and above.
## Usage
```javascript
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: { : } // 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)