Upload multiple files to S3 [v4.1] #1639
Unanswered
brandonsousa
asked this question in
Help
Replies: 2 comments 1 reply
-
Can you please format your code blocks properly. Here's the Github markdown guide https://guides.github.com/features/mastering-markdown/ |
Beta Was this translation helpful? Give feedback.
1 reply
-
You can simply abstract the callback function to it's own function. I don't think this is really related to AdonisJS. However following is an example of same. function streamToS3(file, images) {
const ContentType = file.headers['content-type']
const ACL = 'public-read'
const name = `${new Date().getTime()}.${file.extname}`
return Drive.disk('s3').put(name, file.stream, {
ContentType,
ACL
})
}
request.multipart.file('img_one', validateOptions, async (file) => {
img_one = await streamToS3(file)
})
request.multipart.file('img_two', validateOptions, async (file) => {
img_two = await streamToS3(file)
})
request.multipart.file('img_three', validateOptions, async (file) => {
img_three = await streamToS3(file)
})
await request.multipart.process() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
how to upload 3 images and get the key and url of 3 in s3, i can do 1, as well as 3, but repeating the code to be called in the same request, but I know it is not a good practice.
Beta Was this translation helpful? Give feedback.
All reactions