Closed nbumbarger closed 7 years ago
Hey @jflasher - I wanted to point you towards the way I'm currently handling Amazon uploads, and ask how you might want to handle it in production. Right now there is an API, launched from the server
directory, which receives a filename to an endpoint called s3_credentials
. The page uses the credentials it receives to sign a form including the upload file, which include the parameters:
acl
, key
, policy
, success_action_status
, x-amz-algorithm
, x-amz-credential
, x-amz-date
, and the file.
I imagine that in production you'll want to integrate this kind of endpoint with an existing API, correct? Are you planning to set that up? This implementation works fine if there's a place where it can be slotted in. There's also going to need to be an endpoint on which to validate the users' API keys. Let me know what you think when you have a chance.
Hey @nbumbarger, thanks for looking into this. I haven't implemented any of this yet, but my thought is that on the frontend, you'd do something like api.openaq.org/v1/upload?token=USER_TOKEN&filename=FILENAME
(where USER_TOKEN is the token we've given them and they put in the form and filename can be whatever you want) and it'd return something like
{
"url": "SOME_PRESIGNED_URL"
}
Any errors (most likely wrong token) would lead to a 403 response.
You could then use that pre-signed url like in the response here. I'll probably end up using some of your code to generate that url or I think I can use the SDKs to do that as well. But you shouldn't need to worry about anything AWS specific from the frontend.
Thanks @nbumbarger Just tested it, couple of quick comments:
On Monday I'll do a more thorough review, focusing on how we're presenting the feedback to the users.
@olafveerman @nbumbarger Re changing to node 6: The only problem is that collecticons is not compatible with it, however we're not compiling icons here so it's ok.
@danielfdsilva @olafveerman
This PR adds the upload functionality to the parser. After selecting a file and clicking
Validate CSV
, the parser will convert the CSV to a JSON object and compare its attributes to the schema. If there are no errors, it will allow to proceed with the upload, if there are errors it will currently list them all in a scroll area. I added information about the S3 credential requirements to the README, and for now they can be provided by starting the server file.