Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload File #17

Open
ewwwgiddings opened this issue Mar 1, 2018 · 1 comment
Open

Upload File #17

ewwwgiddings opened this issue Mar 1, 2018 · 1 comment

Comments

@ewwwgiddings
Copy link

ewwwgiddings commented Mar 1, 2018

Has anyone implemented a file upload using Multer as mentioned in one of the videos? Any tips on how?

@ewwwgiddings
Copy link
Author

My solution if anyone is wanting it is on submit of the form send off the formData and userId:

const userId = this.route.params.userId
const response = (await FileUploadService.upload(formData, userId)).data

Then in a file upload service this:

upload(formData, userId){
return api().post(fileupload/${userId}, formData)
}

Then in routes.js on the server side I used multer S3 to send it off to AWS S3 using req.params.userId and the file name (key). Then send the req.body off to a controller like this:

app.post('/fileupload/:userId', upload.single('image'), nameOfController.upload)

There's probably a better way around this, but that's the solution I have used so far to upload images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant