file-upload-proxy (FUP)
Service used to to validate files and sign requests for uploading files to S3.
Uploading to S3
- Get the
signedRequest
from the/sign
endpoint. - Create a
POST
form with the help offields
ofsignedRequest
. - Add the fields below to the form aswell.
acl: public-read
Content-Type
The mime type of the fileContent-Length
The size of the filefile
: Theblobb
of the file
- Submit the form to the
url
in 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 bytes
of the file that is being uploaded as a binary Buffer (Which should set theContent-Type
to 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
:Bearer
token that user is logged in on StoryEngine domain.
-
Query Parameters:
fileName
the name of the file being uploaded.fileSize
size 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.json
and 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.env
variablesASSET_PROXY_
accordingly described below).
- Copy
.env.example
and change name to.env
and updated variables accordingly:AWS_ACCESS_KEY_ID
&AWS_SECRET_ACCESS_KEY
should be set to your personal credentials (can probably be found in CWS.env
).BASIC_AUTH_USER
&BASIC_AUTH_PASS
can be run as default since these are only used when running tests.ASSET_PROXY_PASS
&ASSET_PROXY_USER
depending on if you're running against stage or local KEAP these should be set to the one you're running against.PORT
needs 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