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

Adonis S3 Driver is not working properly #21

Closed
ghost opened this issue Sep 7, 2021 · 5 comments
Closed

Adonis S3 Driver is not working properly #21

ghost opened this issue Sep 7, 2021 · 5 comments
Assignees
Labels
Type: Bug The issue has indentified a bug

Comments

@ghost
Copy link

ghost commented Sep 7, 2021

Hello, im trying to upload images to s3 using the adonis s3 driver, but i am facing an issue with the contentType.

public async store({ request, params }: HttpContextContract) {
  const { file } = await request.validate(StoreValidator)

  const fileName = `${cuid()}.${file.extname}`
  const fileStream = fs.createReadStream(file.tmpPath!)

  await Drive.putStream(fileName, fileStream, {
    contentType: 'image/png' // or file.headers['content-type']
  })
}

As you could see above, im passing the contentType as "image/png", but it doesnt make any change on s3 actually, as you can see below:

68747470733a2f2f692e6962622e636f2f585a674b70664c2f436170747572612d64652d54656c612d323032312d30392d30362d612d732d31302d32312d34392e706e67

@thetutlage
Copy link
Member

Can you please share a repo that helps me reproduce the issue, or create a test in drive-s3 repo that fails to set the content-type?

Coz we already have a test in place that verifies it is working. https://github.com/adonisjs/drive-s3/blob/develop/test/s3-driver.spec.ts#L197-L222

@ghost ghost closed this as completed Sep 8, 2021
@ghost ghost reopened this Sep 8, 2021
@ghost
Copy link
Author

ghost commented Sep 8, 2021

Can you please share a repo that helps me reproduce the issue, or create a test in drive-s3 repo that fails to set the content-type?

Coz we already have a test in place that verifies it is working. https://github.com/adonisjs/drive-s3/blob/develop/test/s3-driver.spec.ts#L197-L222

I have just created this repo: https://github.com/matheus-polska/upload-adonis

To run it, you just need to create a .env file with your bucket infos, and within /start/routes.ts you can find the upload route.

The upload works normally, just the contentType can not be changed

And also i'd like to be sure my endpoint is correct.

@thetutlage
Copy link
Member

Thanks for creating the repo. Looks like a bug with the DriveManager class not forwarding options to the drive. Will work on the fix.

Also, incase you missed it. You can also use the file.moveToDisk method. https://docs.adonisjs.com/guides/drive#bodyparser-movetodisk

@ghost
Copy link
Author

ghost commented Sep 8, 2021

Thanks, do you have an idea when its gonne be fixed? I mean, should i wait or try to find other solutions?

anyways, thanks for the quick support :)

@thetutlage thetutlage transferred this issue from adonisjs/core Sep 9, 2021
@thetutlage thetutlage self-assigned this Sep 9, 2021
@thetutlage thetutlage added the Type: Bug The issue has indentified a bug label Sep 9, 2021
@abdullateefakorede
Copy link

is this issue resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue has indentified a bug
Projects
None yet
Development

No branches or pull requests

2 participants