1.8.0 • Published 5 years ago
file-upload-proxy v1.8.0
file-upload-proxy (FUP)
Service used to to validate files and sign requests for uploading files to S3.
Uploading to S3
- Get the
signedRequestfrom the/signendpoint. - Create a
POSTform with the help offieldsofsignedRequest. - Add the fields below to the form aswell.
acl: public-readContent-TypeThe mime type of the fileContent-LengthThe size of the filefile: Theblobbof the file
- Submit the form to the
urlin thesignedRequest
The order in which the fields in the form are set matters, so the fields in point 3 should be before fields in point 4.
API
/sign
Requirements:
- The first
4100 bytesof the file that is being uploaded as a binary Buffer (Which should set theContent-Typeto whatever mime type the file is, so NOmultipart/form-data) Headers:
Content-Length: Which should be set per auto if uploading a Binary file.Authorization:Bearertoken that user is logged in on StoryEngine domain.
Query Parameters:
fileNamethe name of the file being uploaded.fileSizesize of the file being uploaded
Response:
interface ISignedUpload {
signedRequest: string, /* The URL to which to upload the file. */
url: string /* The URL of the uploaded file. */
}Development
Setup
- Copy
default.jsonand make alocal.json, depending on what you want to do with the application, the configuration differs. Most config options can be changed, and depending on what environment you are running against, these three configs are the ones that need to be adjusted.wpUrl: is used to identify the WP that you're running and it uses the authing from that environment. If you want to run this locally, then set the wpUrl to local WP URL.kesUrl: This can be the same as the default because it can use the stage KES, but change to local KES URL if you want to run locally.eapUrl: This can be the same as the default one because this auth is done with BA (what is BA) and as long as you set the same BA and URL as the stage, it will work fine. If you want to run it locally, input local KEAP URL (You'll need to set the.envvariablesASSET_PROXY_accordingly described below).
- Copy
.env.exampleand change name to.envand updated variables accordingly:AWS_ACCESS_KEY_ID&AWS_SECRET_ACCESS_KEYshould be set to your personal credentials (can probably be found in CWS.env).BASIC_AUTH_USER&BASIC_AUTH_PASScan be run as default since these are only used when running tests.ASSET_PROXY_PASS&ASSET_PROXY_USERdepending on if you're running against stage or local KEAP these should be set to the one you're running against.PORTneeds to be set if you have a conflict or wanna use a custom one.
- You'll need to update the FUP url in the application you're trying to upload files from (default url
http://localhost:1231).
Running
npm run dev