Not able to download media file from strapi CMS v4.11.4

System Information
  • Strapi Version: 4.11.4
  • Operating System: macOS
  • Database: PostgreSQL
  • Node Version: v18.14.0
  • NPM Version: 9.3.1

Not able to download media files from strapi CMS. It gives a bad request error.
All media files are belonging to the s3 bucket.
Here I attached screenshots.

[Screenshot 2023-07-25 at 2.01.56 PM|690x324](upload://ydnJoxbxJdtHongqgLUb06GBv28.png)
[Screenshot 2023-07-25 at 2.04.15 PM|560x246](upload://uHDAVK4BO0YELuYo52oQjV8HrKf.png)
[Screenshot 2023-07-25 at 2.04.27 PM|690x432](upload://9l8YaPDF4Y5qTmKUO1bRROuAQ4l.png)

type or paste code here
1 Like

Does anyone have solution for this?

Same issue is appearing to me. Not able to download images from Strapi.

Check the below console error:

Those lines look like Markdown ‘link’ entries, but the URL portion of each of them (in the round brackets) looks invalid, as it begins with a ‘protocol’ of ‘upload’ - which I am sure will not be recognised by any browser. The URL should [almost certainly] use either HTTP or HTTPS and should include a ‘host’ element, pointing at an S3 service endpoint that can provide content from the corresponding bucket - something like

You should be able to generate or discover a ‘correct’ URL (when an S3 bucket is used) from the upload image browser, and you should get a valid image reference when you use the Strapi rich text editor to embed an image from the media collection. If your media files are being shown in the media browser or Strapi rich text editor with a URL like the ones shown in your question, then the root problem is likely to be that you have not configured the AWS S3 ‘provider’ correctly. It almost certainly lacks a valid ‘endpoint’ configuration parameter in the ‘providerOptions’ object … See Configuration section here and follow the link to ‘Complete list of options’.

Note, too, that the Markdown syntax for an embedded image also requires a leading exclamation mark (!), otherwise it’s likely to be rendered as a plain hyperlink.

I also encountered an issue of not being able to download. The reason for the error is that aws-s3 does not allow Authorization to be carried in the request header

<Error> <Code>InvalidArgument</Code> <Message>Unsupported Authorization Type</Message> <ArgumentName>Authorization</ArgumentName> <Error>

Did you found solution how to fix it?

You need (I think) to configure your S3 bucket to allow unauthenticated access to your uploaded media. If you enable ‘fine grain access control’ then the S3 upload provider can configure that on an object-by-object basis, so only your uploads have unrestricted access. [It can’t do that retrospectively, so you’d need to adjust permissions on every existing uploaded object.]

If you’re only using the uploads in an app that already requires its own authentication, and you don’t want to allow unrestricted access, you’ll need to use a custom plugin that can fetch the uploads with appropriate S3 authorisation. That plugin can then offer an API route and the controller for that route can check that the user is authenticated [has a current session] within your app. Or, if your app is extending the Strapi UI then you can leave the default auth: true on the API route and rely on Strapi login.