Set metadata when uploading images to s3 or spaces

#1

By default the image arrives at s3 with Content-Type: application / octet-stream. How can I change this at upload time? And, if possible, how can I make the object sent public rather than private?

const validations = {
      types: ['image'],
      size: '2mb'
    }

    request.multipart.file('image', validations, async (file) => {
      await Drive.disk('spaces').put(`uploads/${uuid.v4()}.${file.extname}`, file.stream)
    })

    await request.multipart.process()
1 Like

#2

Hi there @clayderson :wave:
I use a third parameter for the put method like this:

await Drive.disk('do').put(fileName, data, {
        ACL: 'public-read',
        ContentType: 'image/jpeg'
      })

to specify the content type and to make the image public
Hope it helps

1 Like

#3

Hi @melokki

Perfect!!! Thank you so much, you saved me from a lot of work.

0 Likes

#4

You’re welcome :slight_smile:

0 Likes