<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Opndrive</title>
    <description>The latest articles on DEV Community by Opndrive (@opndrive).</description>
    <link>https://dev.to/opndrive</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4265737%2Feb0f9474-2d68-436d-9ca7-f6bb5b64e786.png</url>
      <title>DEV Community: Opndrive</title>
      <link>https://dev.to/opndrive</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/opndrive"/>
    <language>en</language>
    <item>
      <title>Fix SignatureDoesNotMatch on Browser Uploads to S3 and S3-Compatible Storage: Compare Signed and Sent Headers</title>
      <dc:creator>Opndrive</dc:creator>
      <pubDate>Thu, 26 Nov 2026 15:14:07 +0000</pubDate>
      <link>https://dev.to/opndrive/fix-signaturedoesnotmatch-on-browser-uploads-to-s3-and-s3-compatible-storage-compare-signed-and-3269</link>
      <guid>https://dev.to/opndrive/fix-signaturedoesnotmatch-on-browser-uploads-to-s3-and-s3-compatible-storage-compare-signed-and-3269</guid>
      <description>&lt;p&gt;Your frontend uploads a file to a presigned URL, and the browser gets &lt;code&gt;403 SignatureDoesNotMatch&lt;/code&gt;. The same URL works from curl or from your server. The error means the storage service rebuilt the signature from the request it received, and the result did not match the one in the URL (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-troubleshooting.html" rel="noopener noreferrer"&gt;AWS, Troubleshoot Signature Version 4&lt;/a&gt;). So the browser sent a request that your signer did not expect.&lt;/p&gt;

&lt;p&gt;This post gives you a short order of checks. First compare what was signed with what the browser sent. Then replay the request with curl. Then fix the one cause the comparison points to. It covers presigned &lt;code&gt;PUT&lt;/code&gt; uploads to Amazon S3, Cloudflare R2, Backblaze B2 and MinIO. Presigned &lt;code&gt;POST&lt;/code&gt; form uploads use a different scheme, and neither R2 (&lt;a href="https://developers.cloudflare.com/r2/api/s3/presigned-urls/" rel="noopener noreferrer"&gt;Cloudflare R2, Presigned URLs&lt;/a&gt;) nor B2 (&lt;a href="https://www.backblaze.com/docs/cloud-storage-s3-compatible-api" rel="noopener noreferrer"&gt;Backblaze B2, S3-Compatible API&lt;/a&gt;) supports them.&lt;/p&gt;

&lt;p&gt;The commands and the program below come from the documentation linked at each step. None of them were run for this post, so try them on a test bucket first.&lt;/p&gt;

&lt;p&gt;In this post:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What SignatureDoesNotMatch means on a browser upload&lt;/li&gt;
&lt;li&gt;The decision order&lt;/li&gt;
&lt;li&gt;Step 1: compare what was signed with what the browser sent&lt;/li&gt;
&lt;li&gt;Step 2: replay the request with curl&lt;/li&gt;
&lt;li&gt;The fixes: Content-Type, SDK checksums, a changed URL, endpoint and region, clock and expiry, the secret key&lt;/li&gt;
&lt;li&gt;A reference signer and upload script&lt;/li&gt;
&lt;li&gt;FAQ and a final checklist&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What SignatureDoesNotMatch means on a browser upload
&lt;/h2&gt;

&lt;p&gt;SignatureDoesNotMatch means the storage service &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-troubleshooting.html" rel="noopener noreferrer"&gt;recomputed the signature&lt;/a&gt; from the request it received and got a different value from the one in your presigned URL. It is not a permissions error. On a browser upload, look for a request that differs from what was signed, or a URL signed with the wrong region, endpoint or secret.&lt;/p&gt;

&lt;p&gt;The permissions case is a different problem. AWS’s presigned-URL FAQ handles it under its own &lt;code&gt;403 Forbidden&lt;/code&gt; question, apart from the SignatureDoesNotMatch question (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS, presigned URLs&lt;/a&gt;). CORS is a different problem too. A browser upload to another origin usually sends an &lt;code&gt;OPTIONS&lt;/code&gt; preflight before the real &lt;code&gt;PUT&lt;/code&gt; (&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request" rel="noopener noreferrer"&gt;MDN, Preflight request&lt;/a&gt;), and a failed preflight is a CORS fix, not a signing fix. This post leaves permissions aside and gives only the CORS steps that Fix B needs.&lt;/p&gt;

&lt;p&gt;The signature covers the HTTP method, the headers and the query string. AWS says all of them must “match exactly between URL generation and usage” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS, presigned URLs&lt;/a&gt;). Only &lt;code&gt;host&lt;/code&gt; and &lt;code&gt;x-amz-*&lt;/code&gt; headers must be signed, and other standard headers such as &lt;code&gt;content-type&lt;/code&gt; are optional (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html" rel="noopener noreferrer"&gt;AWS, Create a signed request&lt;/a&gt;). The same AWS page also says that if the &lt;code&gt;Content-Type&lt;/code&gt; header is present in the request, you must add it to the canonical headers, so treat Content-Type as something you sign on purpose. Change any signed part between signing and sending, and the two signatures differ.&lt;/p&gt;

&lt;h2&gt;
  
  
  The decision order
&lt;/h2&gt;

&lt;p&gt;Work through these steps in order. Each one either finds the cause or rules out a group of causes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Compare &lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt; and the rest of the URL with the &lt;code&gt;PUT&lt;/code&gt; the browser sent (step 1 below). If you test on a local emulator, rerun the request on the real endpoint first.&lt;/li&gt;
&lt;li&gt;Replay the request with curl, to separate browser problems from signer problems (step 2 below).&lt;/li&gt;
&lt;li&gt;Fix by cause: Content-Type, then SDK checksum parameters, an altered URL, endpoint and region, clock and expiry, and last the secret key.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Froe2xix2vlv42pvtnpeo.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Froe2xix2vlv42pvtnpeo.webp" alt="Flowchart of the checks for a browser PUT that returns SignatureDoesNotMatch. If you test on an emulator, rerun on the real endpoint. Then compare X-Amz-SignedHeaders and the URL with the PUT in DevTools and replay with curl. If the curl baseline passes, fix the browser side, Content-Type first and then checksum parameters. If it fails, work down the signer side: changed URL or host, region or endpoint, clock or expiry, then the secret key." width="488" height="2560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The curl baseline splits the work in two. If it passes, the browser changed the request, so fix Content-Type, then checksum parameters. If it fails too, the signer is wrong, so check the URL, region, clock and keys in that order.&lt;/em&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cause&lt;/th&gt;
&lt;th&gt;Where you see it&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Content-Type differs from the signed one&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;content-type&lt;/code&gt; is in &lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt;, and the &lt;code&gt;PUT&lt;/code&gt; in DevTools sends another value&lt;/td&gt;
&lt;td&gt;Sign the exact type and send it explicitly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The SDK added checksum parameters&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;x-amz-checksum-crc32&lt;/code&gt; or &lt;code&gt;x-amz-sdk-checksum-algorithm&lt;/code&gt; in the query string, JavaScript SDK v3 at 3.729.0 or later&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;requestChecksumCalculation: "WHEN_REQUIRED"&lt;/code&gt; on the signing client, or sign the real checksum&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The URL changed after signing&lt;/td&gt;
&lt;td&gt;The path or query in DevTools differs from the generated URL, special characters in the key, a proxy or a custom domain&lt;/td&gt;
&lt;td&gt;Encode the key once, don’t rewrite the URL, call the host you signed for&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong region or endpoint&lt;/td&gt;
&lt;td&gt;The region in &lt;code&gt;X-Amz-Credential&lt;/code&gt; is not the bucket’s region&lt;/td&gt;
&lt;td&gt;Sign with the bucket’s region and the endpoint the browser calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clock skew or an expired URL&lt;/td&gt;
&lt;td&gt;It fails from every client, curl included&lt;/td&gt;
&lt;td&gt;Sync the signer’s clock with NTP and sign a fresh URL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The secret doesn’t belong to the access key ID&lt;/td&gt;
&lt;td&gt;The curl replay and a CLI call with the same keys both fail&lt;/td&gt;
&lt;td&gt;Re-enter or replace the key pair&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An emulator mislabels the error&lt;/td&gt;
&lt;td&gt;It fails only against a local emulator&lt;/td&gt;
&lt;td&gt;Test against the real endpoint&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 1: compare what was signed with what the browser sent
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Before you blame your code: are you on an emulator?
&lt;/h3&gt;

&lt;p&gt;If you test against a local emulator, check this first. An open issue on &lt;code&gt;aws/aws-emulator&lt;/code&gt; (#51, opened 2026-11-12) reports that, with default auth, the emulator answers a presigned request that carries a browser &lt;code&gt;Origin&lt;/code&gt; header with &lt;code&gt;403 SignatureDoesNotMatch&lt;/code&gt;, although the URL signs only &lt;code&gt;host&lt;/code&gt; (&lt;a href="https://github.com/aws/aws-emulator/issues/51" rel="noopener noreferrer"&gt;aws/aws-emulator #51&lt;/a&gt;). The reporter notes: “Users then debug keys, clock skew and signing code instead of the browser-origin check.” A second user narrowed it to &lt;code&gt;Origin&lt;/code&gt; and &lt;code&gt;Sec-Fetch-Site: cross-site&lt;/code&gt;, and wrote that real S3 ignores headers not listed in &lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt;. That is the commenter’s statement, not AWS documentation. The emulator’s README says not to use it “to test security” (&lt;a href="https://github.com/aws/aws-emulator" rel="noopener noreferrer"&gt;aws/aws-emulator&lt;/a&gt;). Run the same request against the real endpoint before you debug your signing code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Read the presigned URL
&lt;/h3&gt;

&lt;p&gt;A Signature Version 4 presigned URL carries its signing inputs in the query string. Here is one broken onto lines for reading. Every value is an example: &lt;code&gt;AKIAIOSFODNN7EXAMPLE&lt;/code&gt; is AWS’s documentation key ID, and the two checksum lines appear only if your SDK added them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://&amp;lt;HOST&amp;gt;/&amp;lt;KEY&amp;gt;
  ?X-Amz-Algorithm=AWS4-HMAC-SHA256
  &amp;amp;X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20261121%2Fus-east-1%2Fs3%2Faws4_request
  &amp;amp;X-Amz-Date=20261121T120000Z
  &amp;amp;X-Amz-Expires=300
  &amp;amp;X-Amz-SignedHeaders=content-type%3Bhost
  &amp;amp;x-amz-checksum-crc32=AAAAAA%3D%3D
  &amp;amp;x-amz-sdk-checksum-algorithm=CRC32
  &amp;amp;X-Amz-Signature=&amp;lt;SIGNATURE&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part of the URL&lt;/th&gt;
&lt;th&gt;What it tells you&lt;/th&gt;
&lt;th&gt;Where it leads&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The header names that were signed: lowercase, sorted, separated by semicolons (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html" rel="noopener noreferrer"&gt;AWS, Create a signed request&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;The comparisons below, and the Content-Type fix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;X-Amz-Credential&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The access key ID, then the date, region, service and &lt;code&gt;aws4_request&lt;/code&gt; (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html" rel="noopener noreferrer"&gt;AWS, Create a signed request&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;The region fix and the secret-key fix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;X-Amz-Date&lt;/code&gt; and &lt;code&gt;X-Amz-Expires&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;When the URL was signed (UTC), and for how many seconds it is valid (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS, presigned URLs&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;The clock and expiry fix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;x-amz-checksum-crc32&lt;/code&gt;, &lt;code&gt;x-amz-sdk-checksum-algorithm&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Checksum parameters an SDK added&lt;/td&gt;
&lt;td&gt;The checksum fix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Host and path&lt;/td&gt;
&lt;td&gt;The hostname and the encoded object key&lt;/td&gt;
&lt;td&gt;The altered-URL fix&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Treat a live presigned URL as a password: anyone who has it can use it until it expires. Don’t paste one into a public issue, and blur the signature and key ID in screenshots.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find the PUT in DevTools, not the OPTIONS
&lt;/h3&gt;

&lt;p&gt;Open the Network panel and select the failed &lt;code&gt;PUT&lt;/code&gt;. Open its &lt;strong&gt;Headers&lt;/strong&gt; tab and scroll to &lt;strong&gt;Request Headers&lt;/strong&gt; (&lt;a href="https://developer.chrome.com/docs/devtools/network/reference" rel="noopener noreferrer"&gt;Chrome DevTools, Network features reference&lt;/a&gt;). An upload to another origin usually shows an &lt;code&gt;OPTIONS&lt;/code&gt; preflight just before it (&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request" rel="noopener noreferrer"&gt;MDN, Preflight request&lt;/a&gt;). Compare the &lt;code&gt;PUT&lt;/code&gt;, not the &lt;code&gt;OPTIONS&lt;/code&gt;. Then open the &lt;strong&gt;Response&lt;/strong&gt; tab of the &lt;code&gt;PUT&lt;/code&gt; to read the error body the service returned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make three comparisons
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Every name in &lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt; appears in &lt;strong&gt;Request Headers&lt;/strong&gt;, with the value the signer used. In practice this is usually the &lt;code&gt;content-type&lt;/code&gt; check.&lt;/li&gt;
&lt;li&gt;The request URL in DevTools matches the generated URL character for character. AWS’s checklist says to use the URL “exactly as generated, without any modifications” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html" rel="noopener noreferrer"&gt;AWS, Uploading objects with presigned URLs&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;No &lt;code&gt;x-amz-*&lt;/code&gt; request header appears that the signer never saw. Every &lt;code&gt;x-amz-*&lt;/code&gt; header belongs in the signature (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html" rel="noopener noreferrer"&gt;AWS, Create a signed request&lt;/a&gt;), so check any your code adds after signing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some headers are out of your hands. &lt;code&gt;Origin&lt;/code&gt; and &lt;code&gt;Host&lt;/code&gt; are forbidden request headers, which “cannot be set or modified programmatically in a request” (&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header" rel="noopener noreferrer"&gt;MDN, Forbidden request header&lt;/a&gt;). If a custom signer included one of them, fix the signer, not the frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: replay the request with curl
&lt;/h2&gt;

&lt;p&gt;A curl replay tells you whether the browser or the signer is at fault. Run two of them.&lt;/p&gt;

&lt;p&gt;The first is the baseline. AWS’s upload example sends the file with curl, with the same Content-Type that was used to create the URL, and with the URL in quotes (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html" rel="noopener noreferrer"&gt;AWS, Uploading objects with presigned URLs&lt;/a&gt;). Add &lt;code&gt;-v&lt;/code&gt; to print every header curl sends and receives (&lt;a href="https://everything.curl.dev/usingcurl/verbose/" rel="noopener noreferrer"&gt;Everything curl, Verbose&lt;/a&gt;). The placeholders are example values to replace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# &amp;lt;PRESIGNED_URL&amp;gt;: the URL your signer returned&lt;/span&gt;
&lt;span class="c"&gt;# &amp;lt;FILE&amp;gt;: a local test file&lt;/span&gt;
&lt;span class="c"&gt;# &amp;lt;SIGNED_TYPE&amp;gt;: the Content-Type you passed when signing, for example image/png&lt;/span&gt;
&lt;span class="nv"&gt;URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;PRESIGNED_URL&amp;gt;'&lt;/span&gt;   &lt;span class="c"&gt;# single quotes keep the &amp;amp; characters intact&lt;/span&gt;
curl -v -X PUT -T &lt;span class="s1"&gt;'&amp;lt;FILE&amp;gt;'&lt;/span&gt; -H &lt;span class="s1"&gt;'Content-Type: &amp;lt;SIGNED_TYPE&amp;gt;'&lt;/span&gt; &lt;span class="s2"&gt;"$URL"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second is the browser’s exact request. In Chrome DevTools, right-click the &lt;code&gt;PUT&lt;/code&gt; and copy it as a cURL command (&lt;a href="https://developer.chrome.com/docs/devtools/network/reference" rel="noopener noreferrer"&gt;Chrome DevTools, Network features reference&lt;/a&gt;). Check that the copied command carries the file. If it doesn’t, add &lt;code&gt;-T '&amp;lt;FILE&amp;gt;'&lt;/code&gt; yourself.&lt;/p&gt;

&lt;p&gt;Read the results like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The baseline fails too.&lt;/strong&gt; The signer, the URL or the keys are wrong, not the browser. Go to the URL, region, clock and secret-key fixes below.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The baseline passes and the browser’s copy fails.&lt;/strong&gt; The browser adds or changes something. Remove the copied headers one at a time until the request passes. The last header you removed is the cause. Start with Content-Type and any &lt;code&gt;x-amz-*&lt;/code&gt; header.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fix a Content-Type that doesn’t match the signature
&lt;/h2&gt;

&lt;p&gt;AWS and Cloudflare both name this cause. AWS’s checklist says to make sure “the content type in your upload request matches the content type specified when generating the URL” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html" rel="noopener noreferrer"&gt;AWS, Uploading objects with presigned URLs&lt;/a&gt;). R2’s docs say the signature includes this header, so uploads fail with &lt;code&gt;403/SignatureDoesNotMatch&lt;/code&gt; if the client sends a different Content-Type (&lt;a href="https://developers.cloudflare.com/r2/api/s3/presigned-urls/" rel="noopener noreferrer"&gt;Cloudflare R2, Presigned URLs&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The browser takes its value from the file. When the body is a &lt;code&gt;File&lt;/code&gt; or &lt;code&gt;Blob&lt;/code&gt; whose &lt;code&gt;type&lt;/code&gt; is not empty, the Fetch Standard uses that type for the request (&lt;a href="https://fetch.spec.whatwg.org/#bodyinit-unions" rel="noopener noreferrer"&gt;Fetch Standard, extract a body&lt;/a&gt;). So the header follows &lt;code&gt;file.type&lt;/code&gt;, which depends on the file the user picked. Decide the type when you sign, sign it on purpose, and send exactly that value.&lt;/p&gt;

&lt;p&gt;In the browser, set the header to the value you signed instead of relying on &lt;code&gt;file.type&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// signedType: the Content-Type your server signed and returned with the URL (example: "image/png")&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"PUT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;signedType&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Upload failed: HTTP ${res.status}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the signer, with the AWS SDK for JavaScript v3, pass &lt;code&gt;ContentType&lt;/code&gt; on &lt;code&gt;PutObjectCommand&lt;/code&gt; and add &lt;code&gt;content-type&lt;/code&gt; to the presigner’s &lt;code&gt;signableHeaders&lt;/code&gt;, so the header is enforced (&lt;a href="https://github.com/aws/aws-sdk-js-v3/blob/main/packages/s3-request-presigner/README.md" rel="noopener noreferrer"&gt;&lt;code&gt;@aws-sdk/s3-request-presigner&lt;/code&gt; README&lt;/a&gt;). Then sign a URL and check that &lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt; lists &lt;code&gt;content-type&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you sign for R2 with &lt;code&gt;aws4fetch&lt;/code&gt;, Cloudflare says to set &lt;code&gt;allHeaders: true&lt;/code&gt; so the Content-Type header is signed (&lt;a href="https://developers.cloudflare.com/r2/api/s3/presigned-urls/" rel="noopener noreferrer"&gt;Cloudflare R2, Presigned URLs&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix checksum parameters the JavaScript SDK added
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What changed in SDK 3.729.0
&lt;/h3&gt;

&lt;p&gt;From version 3.729.0, the AWS SDK for JavaScript calculates a CRC32 checksum for uploads by default (&lt;a href="https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/s3-checksums.html" rel="noopener noreferrer"&gt;AWS SDK for JavaScript v3, S3 checksums&lt;/a&gt;). That version was released on 2025-01-15 (&lt;a href="https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.729.0" rel="noopener noreferrer"&gt;v3.729.0 release notes&lt;/a&gt;). If uploads broke after you updated &lt;code&gt;@aws-sdk/client-s3&lt;/code&gt;, look here.&lt;/p&gt;

&lt;p&gt;The setting is &lt;code&gt;requestChecksumCalculation&lt;/code&gt; in the JavaScript client config (&lt;a href="https://github.com/aws/aws-sdk-js-v3/issues/6810" rel="noopener noreferrer"&gt;aws-sdk-js-v3 #6810&lt;/a&gt;), &lt;code&gt;request_checksum_calculation&lt;/code&gt; in the shared config file, or the &lt;code&gt;AWS_REQUEST_CHECKSUM_CALCULATION&lt;/code&gt; environment variable. The default is &lt;code&gt;WHEN_SUPPORTED&lt;/code&gt;. With &lt;code&gt;WHEN_REQUIRED&lt;/code&gt;, checksums are calculated only when the operation requires one (&lt;a href="https://docs.aws.amazon.com/sdkref/latest/guide/feature-dataintegrity.html" rel="noopener noreferrer"&gt;AWS SDKs and Tools, Data integrity protections&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  One report of the failure
&lt;/h3&gt;

&lt;p&gt;Here is what it looked like in one report. In a January 2025 forum post about Tigris storage, a presigned &lt;code&gt;PUT&lt;/code&gt; URL from &lt;code&gt;getSignedUrl&lt;/code&gt; carried &lt;code&gt;x-amz-checksum-crc32=AAAAAA%3D%3D&lt;/code&gt; and &lt;code&gt;x-amz-sdk-checksum-algorithm=CRC32&lt;/code&gt;. The &lt;code&gt;PUT&lt;/code&gt; got SignatureDoesNotMatch, and &lt;code&gt;requestChecksumCalculation: 'WHEN_REQUIRED'&lt;/code&gt; on the client fixed it (&lt;a href="https://community.fly.io/t/signaturedoesnotmatch-when-using-pre-signed-url-with-aws-sdk/23549" rel="noopener noreferrer"&gt;Fly.io community forum&lt;/a&gt;). That is one practitioner’s report, not vendor documentation.&lt;/p&gt;

&lt;p&gt;Our reading of why it fails, not from a cited source: &lt;code&gt;AAAAAA==&lt;/code&gt; decodes to four zero bytes, and by our calculation that is the CRC32 of an empty body. A presigned URL is made before the file exists, so this looks like a checksum of nothing, not of the file the browser sends later. AWS also says an upload that uses these checksum algorithms must “include the appropriate checksum header in your upload request” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS, presigned URLs&lt;/a&gt;). A checksum built into the URL is a condition the browser’s upload then has to meet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fix A: turn off default checksums on S3-compatible providers
&lt;/h3&gt;

&lt;p&gt;Set &lt;code&gt;requestChecksumCalculation: "WHEN_REQUIRED"&lt;/code&gt; on the client that signs the URL. In the SDK’s announcement thread, users reported that the default change broke R2 and B2. Those are user comments. The maintainers replied that the SDK “is designed to work with AWS services” and pointed users of other services to their provider’s documentation (&lt;a href="https://github.com/aws/aws-sdk-js-v3/issues/6810" rel="noopener noreferrer"&gt;aws-sdk-js-v3 #6810&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Fix B: keep the integrity check on Amazon S3
&lt;/h3&gt;

&lt;p&gt;The same maintainers “recommend not to disable default data integrity protections with Amazon S3” (&lt;a href="https://github.com/aws/aws-sdk-js-v3/issues/6810" rel="noopener noreferrer"&gt;aws-sdk-js-v3 #6810&lt;/a&gt;). To keep a checksum, compute the file’s SHA-256 in the browser and send it to your server. Sign it on &lt;code&gt;PutObjectCommand&lt;/code&gt;, and list its header in the presigner’s &lt;code&gt;unhoistableHeaders&lt;/code&gt;, which forces that header to be present in the upload request (&lt;a href="https://github.com/aws/aws-sdk-js-v3/blob/main/packages/s3-request-presigner/README.md" rel="noopener noreferrer"&gt;&lt;code&gt;@aws-sdk/s3-request-presigner&lt;/code&gt; README&lt;/a&gt;). A pre-calculated checksum turns off the SDK’s automatic one (&lt;a href="https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/s3-checksums.html" rel="noopener noreferrer"&gt;AWS SDK for JavaScript v3, S3 checksums&lt;/a&gt;). The browser then sends the same value as a header, and the bucket’s CORS rules must allow that header. This flow is untested:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Server side. checksumBase64 is the Base64 SHA-256 of the file, computed in the browser.&lt;/span&gt;
&lt;span class="c1"&gt;// client, signedType, &amp;lt;BUCKET&amp;gt; and &amp;lt;KEY&amp;gt; are as in the full program further down.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getSignedUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PutObjectCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;BUCKET&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;KEY&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;ContentType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;signedType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;ChecksumSHA256&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;checksumBase64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;signableHeaders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"content-type"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;unhoistableHeaders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"x-amz-checksum-sha256"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Browser side: send the same two values as headers.&lt;/span&gt;
&lt;span class="c1"&gt;// headers: { "Content-Type": signedType, "x-amz-checksum-sha256": checksumBase64 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Check this on your own SDK version.&lt;/strong&gt; The only presigned &lt;code&gt;PUT&lt;/code&gt; evidence above is one forum report from January 2025. The presigner README describes a default of “not hoisting any headers that begin with x-amz-*”, which does not fit that report. Other providers may answer the same problem with a different error code. Sign a URL with your current SDK and look for checksum parameters in it before you pick Fix A or Fix B.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Console steps: allow the upload headers in CORS
&lt;/h3&gt;

&lt;p&gt;The bucket’s CORS rules must list every header the browser’s &lt;code&gt;PUT&lt;/code&gt; sends. The browser’s &lt;code&gt;OPTIONS&lt;/code&gt; preflight names those headers in &lt;code&gt;Access-Control-Request-Headers&lt;/code&gt; (&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request" rel="noopener noreferrer"&gt;MDN, Preflight request&lt;/a&gt;), and a policy that does not allow them refuses the preflight. For Fix B that means &lt;code&gt;Content-Type&lt;/code&gt; and &lt;code&gt;x-amz-checksum-sha256&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On Amazon S3, these steps follow &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/enabling-cors-examples.html" rel="noopener noreferrer"&gt;AWS, Configuring cross-origin resource sharing (CORS)&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign in to the AWS Management Console and open the Amazon S3 console.&lt;/li&gt;
&lt;li&gt;In the left navigation pane, choose &lt;strong&gt;General purpose buckets&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the buckets list, choose the name of your bucket.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Permissions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Cross-origin resource sharing (CORS)&lt;/strong&gt; section, choose &lt;strong&gt;Edit&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;CORS configuration editor&lt;/strong&gt;, enter a JSON configuration. Include &lt;code&gt;PUT&lt;/code&gt; in &lt;code&gt;AllowedMethods&lt;/code&gt;, your site’s origin in &lt;code&gt;AllowedOrigins&lt;/code&gt;, and the two header names above in &lt;code&gt;AllowedHeaders&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Save changes&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On Cloudflare R2, these steps follow &lt;a href="https://developers.cloudflare.com/r2/buckets/cors/" rel="noopener noreferrer"&gt;Cloudflare R2, Configure CORS&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the Cloudflare dashboard, go to the &lt;strong&gt;R2 object storage&lt;/strong&gt; page.&lt;/li&gt;
&lt;li&gt;Select your bucket.&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;Settings&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;CORS Policy&lt;/strong&gt;, choose &lt;strong&gt;Add CORS policy&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;JSON&lt;/strong&gt; tab, enter the policy with the same three fields.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On other providers, use that provider’s CORS setting as its documentation describes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix a URL that changed after signing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Key encoding
&lt;/h3&gt;

&lt;p&gt;The signed path encodes every byte except the unreserved characters, and AWS says to encode the forward slash “everywhere except in the object key name” (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html" rel="noopener noreferrer"&gt;AWS, Create a signed request&lt;/a&gt;). A space must be &lt;code&gt;%20&lt;/code&gt;, not &lt;code&gt;+&lt;/code&gt; (same page). If the signer encodes the key one way and the request carries it another way, the signatures differ.&lt;/p&gt;

&lt;p&gt;For a key that contained &lt;code&gt;=&lt;/code&gt;, the SDK maintainers’ answer was to “URI-encode the key parameter”. The reporter’s working fix was to split the key on &lt;code&gt;/&lt;/code&gt; and run &lt;code&gt;encodeURIComponent&lt;/code&gt; on each segment. A commenter reported that parentheses still failed (&lt;a href="https://github.com/aws/aws-sdk-js-v3/discussions/4862" rel="noopener noreferrer"&gt;aws-sdk-js-v3 discussion #4862&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Self-hosted servers can be strict about encoding. In 2020 a MinIO maintainer closed a case where a client sent an unescaped &lt;code&gt;;&lt;/code&gt; in a presigned query value, and told the reporter to “fix the client code and escape it yourself” (&lt;a href="https://github.com/minio/minio/issues/8897" rel="noopener noreferrer"&gt;minio/minio #8897&lt;/a&gt;). GitHub shows that repository as archived since 2026-04-25, so treat it as a dated answer.&lt;/p&gt;

&lt;p&gt;The simplest way out is to generate keys from a safe character set on your server. Keep the user’s original file name in object metadata or your database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Proxies, gateways and rewritten hosts
&lt;/h3&gt;

&lt;p&gt;AWS warns that “some corporate proxies might modify headers or query strings”, and says to test without the proxy (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS, presigned URLs&lt;/a&gt;). The &lt;code&gt;host&lt;/code&gt; header is always signed (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html" rel="noopener noreferrer"&gt;AWS, Create a signed request&lt;/a&gt;), so a reverse proxy that changes &lt;code&gt;Host&lt;/code&gt; or the path breaks the signature.&lt;/p&gt;

&lt;p&gt;A MinIO maintainer wrote in 2018 that you “cannot rewrite URLs”, and that the presigned URL should be generated for the address the client uses (&lt;a href="https://github.com/minio/minio/issues/6853" rel="noopener noreferrer"&gt;minio/minio #6853&lt;/a&gt;). Sign with the same public hostname the browser will call.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cloudflare R2: custom domains and changed parameters
&lt;/h3&gt;

&lt;p&gt;Cloudflare says R2 presigned URLs work with the S3 API domain (&lt;code&gt;&amp;lt;ACCOUNT_ID&amp;gt;.r2.cloudflarestorage.com&lt;/code&gt;) “and cannot be used with custom domains” (&lt;a href="https://developers.cloudflare.com/r2/api/s3/presigned-urls/" rel="noopener noreferrer"&gt;Cloudflare R2, Presigned URLs&lt;/a&gt;). The same page says that modifying “the resource, operation, or expiry” gives &lt;code&gt;403/SignatureDoesNotMatch&lt;/code&gt;. Sign for the S3 API domain, and don’t add or remove query parameters after signing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix the endpoint and region
&lt;/h2&gt;

&lt;p&gt;The signature is scoped to a region. AWS’s checklist says to “confirm you’re using the correct region for the bucket” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html" rel="noopener noreferrer"&gt;AWS, Uploading objects with presigned URLs&lt;/a&gt;). The IAM guide adds that when the credential scope names a different region from the request, signature verification fails (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-troubleshooting.html" rel="noopener noreferrer"&gt;AWS, Troubleshoot Signature Version 4&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;You can check this without a console. Read the region in &lt;code&gt;X-Amz-Credential&lt;/code&gt;, then compare it with the bucket’s region. On AWS, paginated &lt;code&gt;ListBuckets&lt;/code&gt; requests return each bucket’s name and its region (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/list-buckets.html" rel="noopener noreferrer"&gt;AWS, Listing general purpose buckets&lt;/a&gt;). In this example command, &lt;code&gt;&amp;lt;BUCKET&amp;gt;&lt;/code&gt; is your bucket name and the numbers are example page sizes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3api list-buckets --prefix &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;BUCKET&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; --max-items 10 --page-size 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On R2, the region is a placeholder. Cloudflare’s SDK example sets &lt;code&gt;region: "auto"&lt;/code&gt; with the comment “Required by SDK but not used by R2”, and uses the endpoint &lt;code&gt;https://&amp;lt;ACCOUNT_ID&amp;gt;.r2.cloudflarestorage.com&lt;/code&gt; (&lt;a href="https://developers.cloudflare.com/r2/examples/aws/aws-sdk-js-v3/" rel="noopener noreferrer"&gt;Cloudflare R2, aws-sdk-js-v3 example&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;On B2 and MinIO, use the endpoint and region that the provider’s own setup documentation gives for your bucket or server. Whatever the provider, the endpoint you sign for must be the host the browser calls, for the same reason as the proxy case above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix clock skew and expired URLs
&lt;/h2&gt;

&lt;p&gt;AWS says to keep the system clock in sync with an NTP server, because “even small time drifts can invalidate signatures” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS, presigned URLs&lt;/a&gt;). The signer writes its own time into &lt;code&gt;X-Amz-Date&lt;/code&gt;, so check the clock on the machine that signs. AWS doesn’t say which clock matters for a presigned URL; that part is our inference.&lt;/p&gt;

&lt;p&gt;AWS’s checklist also says to “check if the URL has expired and generate a new one if needed” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html" rel="noopener noreferrer"&gt;AWS, Uploading objects with presigned URLs&lt;/a&gt;). Compare &lt;code&gt;X-Amz-Date&lt;/code&gt; plus &lt;code&gt;X-Amz-Expires&lt;/code&gt; with the current UTC time. If a URL fails from curl, the browser and your server alike, and the keys check out, look at the clock and the expiry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix a secret that doesn’t belong to the access key ID
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Test the key pair with a known working tool
&lt;/h3&gt;

&lt;p&gt;The secret must belong to the access key ID that signed the URL. AWS lists “The secret access key does not match the access key ID that you specified” as a cause, and says to verify the pair “with a known working implementation” (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-troubleshooting.html" rel="noopener noreferrer"&gt;AWS, Troubleshoot Signature Version 4&lt;/a&gt;). On AWS, the AWS CLI is one: run the &lt;code&gt;list-buckets&lt;/code&gt; command above with the same keys. If it also fails with SignatureDoesNotMatch, the pair is wrong. Also check that the access key ID in &lt;code&gt;X-Amz-Credential&lt;/code&gt; is the one you meant to use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Console steps: create a new access key pair on AWS
&lt;/h3&gt;

&lt;p&gt;You can’t view a secret again after you create it, so if it is lost or mangled, create a new pair. These steps follow &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access-key-self-managed.html" rel="noopener noreferrer"&gt;AWS, Manage your own access keys&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign in to the &lt;strong&gt;IAM console&lt;/strong&gt; with your account ID or alias, your IAM user name and your password.&lt;/li&gt;
&lt;li&gt;In the navigation bar on the upper right, choose your user name, then choose &lt;strong&gt;Security credentials&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Access keys&lt;/strong&gt; section, choose &lt;strong&gt;Create access key&lt;/strong&gt;. If you already have two access keys, this button is deactivated, and you must delete one first.&lt;/li&gt;
&lt;li&gt;On the &lt;strong&gt;Access key best practices &amp;amp; alternatives&lt;/strong&gt; page, choose your use case. If you still need a long-term key, choose &lt;strong&gt;Other&lt;/strong&gt;, then choose &lt;strong&gt;Next&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Optionally set a description tag value, then choose &lt;strong&gt;Create access key&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On the &lt;strong&gt;Retrieve access keys&lt;/strong&gt; page, choose &lt;strong&gt;Show&lt;/strong&gt; or &lt;strong&gt;Download .csv file&lt;/strong&gt;. AWS calls this “your only opportunity to save your secret access key”. Then choose &lt;strong&gt;Done&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Put the new pair into the signer’s configuration and rerun the curl baseline. Then deactivate the old key: in the &lt;strong&gt;Access keys&lt;/strong&gt; section, choose &lt;strong&gt;Actions&lt;/strong&gt;, then &lt;strong&gt;Deactivate&lt;/strong&gt; (same AWS page). Keep the secret on the server that signs. The browser never needs it to use a presigned URL.&lt;/p&gt;

&lt;h3&gt;
  
  
  Console steps: create a new R2 API token
&lt;/h3&gt;

&lt;p&gt;These steps follow &lt;a href="https://developers.cloudflare.com/r2/api/tokens/" rel="noopener noreferrer"&gt;Cloudflare R2, API tokens&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the Cloudflare dashboard, go to the &lt;strong&gt;R2 object storage&lt;/strong&gt; page, then &lt;strong&gt;Overview&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Account Details&lt;/strong&gt;, select &lt;strong&gt;Manage&lt;/strong&gt; next to &lt;strong&gt;API Tokens&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Create Account API token&lt;/strong&gt; or &lt;strong&gt;Create User API token&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Permissions&lt;/strong&gt;, choose a permission type. If you choose &lt;strong&gt;Object Read and Write&lt;/strong&gt; or &lt;strong&gt;Object Read&lt;/strong&gt;, you can limit the token to specific buckets. Then select &lt;strong&gt;Create Account API token&lt;/strong&gt; or &lt;strong&gt;Create User API token&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;Access Key ID&lt;/strong&gt; and the &lt;strong&gt;Secret Access Key&lt;/strong&gt;. Cloudflare says you will not be able to see the secret again after this step.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On other providers, replace the key pair in that provider’s console or admin tool, as its documentation describes.&lt;/p&gt;

&lt;h2&gt;
  
  
  A reference signer and upload script (AWS SDK for JavaScript v3)
&lt;/h2&gt;

&lt;p&gt;When your app fails, it helps to compare it with a small program built only from the documented settings. This one signs a &lt;code&gt;PUT&lt;/code&gt; URL with the Content-Type and checksum fixes applied, prints what was signed, and uploads a file with Node’s &lt;code&gt;fetch&lt;/code&gt;, sending the same Content-Type a browser would. Node sends no &lt;code&gt;Origin&lt;/code&gt; header and no preflight, so the script tests the signature, not CORS. It is built from the presigner README (&lt;a href="https://github.com/aws/aws-sdk-js-v3/blob/main/packages/s3-request-presigner/README.md" rel="noopener noreferrer"&gt;&lt;code&gt;@aws-sdk/s3-request-presigner&lt;/code&gt;&lt;/a&gt;), the SDK’s checksum settings (&lt;a href="https://docs.aws.amazon.com/sdkref/latest/guide/feature-dataintegrity.html" rel="noopener noreferrer"&gt;AWS SDKs and Tools, Data integrity protections&lt;/a&gt;) and Cloudflare’s client example (&lt;a href="https://developers.cloudflare.com/r2/examples/aws/aws-sdk-js-v3/" rel="noopener noreferrer"&gt;Cloudflare R2, aws-sdk-js-v3 example&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Untested:&lt;/strong&gt; this program has not run against a bucket or a demo server. Try it on a test bucket first. The values in angle brackets are placeholders, and the environment variable names are examples you can change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// presign-and-put.mjs&lt;/span&gt;
&lt;span class="c1"&gt;// Sign a presigned PUT URL the way a browser upload needs it, print what was&lt;/span&gt;
&lt;span class="c1"&gt;// signed, then upload a file to it with the same Content-Type a browser sends.&lt;/span&gt;
&lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="c1"&gt;// Setup (a Node.js version with the global fetch):&lt;/span&gt;
&lt;span class="c1"&gt;//   npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner&lt;/span&gt;
&lt;span class="c1"&gt;// Run:&lt;/span&gt;
&lt;span class="c1"&gt;//   ACCESS_KEY_ID=&amp;lt;ACCESS_KEY_ID&amp;gt; SECRET_ACCESS_KEY=&amp;lt;SECRET_ACCESS_KEY&amp;gt; node presign-and-put.mjs&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;readFile&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:fs/promises"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;S3Client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PutObjectCommand&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@aws-sdk/client-s3"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;getSignedUrl&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@aws-sdk/s3-request-presigner"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;BUCKET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;BUCKET&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;KEY&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                   &lt;span class="c1"&gt;// example: uploads/test.png (safe characters only)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;FILE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;PATH_TO_FILE&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;CONTENT_TYPE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;CONTENT_TYPE&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// example: image/png, the exact value the browser will send&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;REGION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;REGION&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;             &lt;span class="c1"&gt;// the bucket's region; "auto" on R2&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;ENDPOINT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;ENDPOINT&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="c1"&gt;// R2: https://&amp;lt;ACCOUNT_ID&amp;gt;.r2.cloudflarestorage.com&lt;/span&gt;
                                       &lt;span class="c1"&gt;// other S3-compatible services: their endpoint&lt;/span&gt;
                                       &lt;span class="c1"&gt;// Amazon S3: set to "" to use the default endpoint&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;S3Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;REGION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;ENDPOINT&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;ENDPOINT&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;accessKeyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ACCESS_KEY_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;secretAccessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SECRET_ACCESS_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// From SDK 3.729.0 a CRC32 checksum is added by default. Calculate checksums&lt;/span&gt;
  &lt;span class="c1"&gt;// only when an operation requires one, so none ends up in the URL.&lt;/span&gt;
  &lt;span class="n"&gt;requestChecksumCalculation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"WHEN_REQUIRED"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getSignedUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PutObjectCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ContentType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;CONTENT_TYPE&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                              &lt;span class="c1"&gt;// seconds&lt;/span&gt;
        &lt;span class="n"&gt;signableHeaders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"content-type"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// enforce the Content-Type&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Could not sign the URL: ${err.name}: ${err.message}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// What was signed: compare these with the browser's request in DevTools.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"X-Amz-SignedHeaders:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"X-Amz-SignedHeaders"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"X-Amz-Credential:   "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"X-Amz-Credential"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"x-amz-checksum"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"x-amz-sdk-checksum-algorithm"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Checksum parameter:  ${name}=${value}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;readFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;FILE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"PUT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;CONTENT_TYPE&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// must equal the signed value&lt;/span&gt;
      &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Upload did not get a response: ${err.message}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Upload failed: HTTP ${res.status}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// the error body the service returned&lt;/span&gt;
    &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Uploaded ${FILE} to ${BUCKET}/${KEY} (HTTP ${res.status}, ETag ${res.headers.get("etag")})`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your self-hosted server expects path-style URLs, add the client setting that its documentation gives for the SDK. The printed &lt;code&gt;X-Amz-Credential&lt;/code&gt; contains your access key ID, and the URL works for anyone until it expires, so keep both out of public issues.&lt;/p&gt;

&lt;p&gt;How to use the result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If this script uploads and your app does not, compare the printed &lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt; and query parameters with your app’s URL, then go back to step 1.&lt;/li&gt;
&lt;li&gt;If this script fails too, look at the keys, the region, the endpoint and the clock.&lt;/li&gt;
&lt;li&gt;On Amazon S3, weigh Fix B from the checksum section instead of &lt;code&gt;WHEN_REQUIRED&lt;/code&gt;, since the SDK maintainers recommend keeping the default protections there (&lt;a href="https://github.com/aws/aws-sdk-js-v3/issues/6810" rel="noopener noreferrer"&gt;aws-sdk-js-v3 #6810&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why does my presigned URL work with curl but fail in the browser?
&lt;/h3&gt;

&lt;p&gt;The browser sends headers that your curl command doesn’t, such as a Content-Type taken from the file (&lt;a href="https://fetch.spec.whatwg.org/#bodyinit-unions" rel="noopener noreferrer"&gt;Fetch Standard&lt;/a&gt;). If the URL was signed with a different Content-Type, or the SDK added checksum parameters, the signatures differ. Compare &lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt; with the &lt;code&gt;PUT&lt;/code&gt; in DevTools, then see the Content-Type and checksum fixes above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does SignatureDoesNotMatch mean my IAM policy is wrong?
&lt;/h3&gt;

&lt;p&gt;No. It means the signature the service calculated from your request differs from the one you sent (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-troubleshooting.html" rel="noopener noreferrer"&gt;AWS, Troubleshoot Signature Version 4&lt;/a&gt;). AWS’s presigned-URL FAQ answers permission problems under a separate &lt;code&gt;403 Forbidden&lt;/code&gt; question (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS, presigned URLs&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Can CORS cause SignatureDoesNotMatch?
&lt;/h3&gt;

&lt;p&gt;CORS problems show up on the &lt;code&gt;OPTIONS&lt;/code&gt; preflight, which is a separate request from the &lt;code&gt;PUT&lt;/code&gt; (&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request" rel="noopener noreferrer"&gt;MDN, Preflight request&lt;/a&gt;). Compare the &lt;code&gt;PUT&lt;/code&gt;‘s headers with the signature, not the preflight’s. One open issue reports a local emulator that answers a browser &lt;code&gt;Origin&lt;/code&gt; header with SignatureDoesNotMatch (&lt;a href="https://github.com/aws/aws-emulator/issues/51" rel="noopener noreferrer"&gt;aws/aws-emulator #51&lt;/a&gt;), so test the real endpoint before you change your signing code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does it fail only for some file names?
&lt;/h3&gt;

&lt;p&gt;Characters in the key were probably encoded one way by the signer and another way in the request. AWS’s signing rules leave &lt;code&gt;/&lt;/code&gt; unencoded in the key and encode a space as &lt;code&gt;%20&lt;/code&gt;, not &lt;code&gt;+&lt;/code&gt; (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html" rel="noopener noreferrer"&gt;AWS, Create a signed request&lt;/a&gt;). Generate keys from safe characters on the server, and see the key encoding section above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why did uploads start failing after I updated the AWS SDK for JavaScript?
&lt;/h3&gt;

&lt;p&gt;From 3.729.0 the SDK calculates a CRC32 checksum for uploads by default (&lt;a href="https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/s3-checksums.html" rel="noopener noreferrer"&gt;AWS SDK for JavaScript v3, S3 checksums&lt;/a&gt;). One forum report shows the checksum parameters ending up in a presigned &lt;code&gt;PUT&lt;/code&gt; URL, fixed with &lt;code&gt;requestChecksumCalculation: 'WHEN_REQUIRED'&lt;/code&gt; (&lt;a href="https://community.fly.io/t/signaturedoesnotmatch-when-using-pre-signed-url-with-aws-sdk/23549" rel="noopener noreferrer"&gt;Fly.io community forum&lt;/a&gt;). Sign a URL and look for &lt;code&gt;x-amz-checksum-*&lt;/code&gt; parameters in it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I use an R2 presigned URL on my custom domain?
&lt;/h3&gt;

&lt;p&gt;No. Cloudflare says R2 presigned URLs work with the S3 API domain, &lt;code&gt;&amp;lt;ACCOUNT_ID&amp;gt;.r2.cloudflarestorage.com&lt;/code&gt;, and cannot be used with custom domains (&lt;a href="https://developers.cloudflare.com/r2/api/s3/presigned-urls/" rel="noopener noreferrer"&gt;Cloudflare R2, Presigned URLs&lt;/a&gt;). Sign for that domain and let the browser call it directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check it in this order
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Read &lt;code&gt;X-Amz-SignedHeaders&lt;/code&gt; and &lt;code&gt;X-Amz-Credential&lt;/code&gt; in the presigned URL.&lt;/li&gt;
&lt;li&gt;Compare them with the &lt;strong&gt;Request Headers&lt;/strong&gt; of the &lt;code&gt;PUT&lt;/code&gt;, not the &lt;code&gt;OPTIONS&lt;/code&gt;, in DevTools.&lt;/li&gt;
&lt;li&gt;Replay with curl and see whether the baseline passes.&lt;/li&gt;
&lt;li&gt;If the baseline passes, fix the browser side: Content-Type first, then checksum parameters.&lt;/li&gt;
&lt;li&gt;If it fails, fix the signer side: the URL and host, then the region and endpoint, then the clock, then the keys. Test against the real endpoint, not an emulator.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Try Opndrive
&lt;/h2&gt;

&lt;p&gt;Opndrive gives any S3-compatible bucket a Drive-like web interface you host yourself.&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/Opndrive/opndrive" rel="noopener noreferrer"&gt;See it on GitHub&lt;/a&gt; or &lt;a href="https://docs.opndrive.app" rel="noopener noreferrer"&gt;read the docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First published on &lt;a href="https://opndrive.app/blog/fix-signaturedoesnotmatch-on-browser-uploads-to-s3-and-s3-compatible" rel="noopener noreferrer"&gt;opndrive.app&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>backend</category>
      <category>cloud</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Fix CORS Errors on a MinIO Bucket: Community vs AIStor, and How to Test the Preflight with curl</title>
      <dc:creator>Opndrive</dc:creator>
      <pubDate>Thu, 26 Nov 2026 15:13:49 +0000</pubDate>
      <link>https://dev.to/opndrive/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test-the-preflight-with-curl-4mc3</link>
      <guid>https://dev.to/opndrive/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test-the-preflight-with-curl-4mc3</guid>
      <description>&lt;p&gt;Your browser app fails on its first request to the bucket. Firefox reports &lt;code&gt;Reason: CORS header 'Access-Control-Allow-Origin' missing&lt;/code&gt; (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors/CORSMissingAllowOrigin" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;); Chromium’s internal name for it is &lt;code&gt;MissingAllowOriginHeader&lt;/code&gt; (&lt;a href="https://github.com/chromium/chromium/blob/main/services/network/public/mojom/cors.mojom" rel="noopener noreferrer"&gt;Chromium source&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;A MinIO CORS error is harder to fix than the same error on Amazon S3, because where CORS lives depends on which MinIO you run: an S3-style bucket CORS document stores nothing on community MinIO (&lt;a href="https://github.com/minio/minio/blob/master/cmd/dummy-handlers.go" rel="noopener noreferrer"&gt;dummy-handlers.go&lt;/a&gt;). Find your build, set CORS at the layer it supports, then prove it with curl.&lt;/p&gt;

&lt;p&gt;Nothing here was run against a live server. The community MinIO responses below are what MinIO’s source code says you should see, read from the archived &lt;code&gt;minio/minio&lt;/code&gt; repository.&lt;/p&gt;

&lt;p&gt;In this post:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test#where-minio-sets-cors-depends-on-the-build" rel="noopener noreferrer"&gt;Where MinIO sets CORS depends on the build&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test#which-browser-error-do-you-have" rel="noopener noreferrer"&gt;Which browser error do you have?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test#find-out-which-minio-you-are-running" rel="noopener noreferrer"&gt;Find out which MinIO you are running&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test#fix-it-on-community-minio-set-the-server-wide-origin-list" rel="noopener noreferrer"&gt;Fix it on community MinIO&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test#fix-it-on-aistor-per-bucket-rules-with-mc-cors-set" rel="noopener noreferrer"&gt;Fix it on AIStor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test#test-the-preflight-with-curl-then-the-real-request" rel="noopener noreferrer"&gt;Test the preflight with curl&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test#behind-a-reverse-proxy-let-one-layer-set-cors" rel="noopener noreferrer"&gt;Behind a reverse proxy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test#presigned-urls-dont-get-you-past-cors" rel="noopener noreferrer"&gt;Presigned URLs and CORS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where MinIO sets CORS depends on the build
&lt;/h2&gt;

&lt;p&gt;Community MinIO has no per-bucket CORS. It uses one server-wide origin list, &lt;code&gt;api cors_allow_origin&lt;/code&gt; (or &lt;code&gt;MINIO_API_CORS_ALLOW_ORIGIN&lt;/code&gt;), which defaults to &lt;code&gt;*&lt;/code&gt; (&lt;a href="https://github.com/minio/minio/blob/master/docs/config/README.md" rel="noopener noreferrer"&gt;config README&lt;/a&gt;). Its &lt;code&gt;PutBucketCors&lt;/code&gt; answers &lt;code&gt;NotImplemented&lt;/code&gt;. MinIO AIStor has the same server-wide list, plus per-bucket S3 XML rules set with &lt;code&gt;mc cors set&lt;/code&gt;. A bucket with its own rules ignores the global list (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor docs&lt;/a&gt;).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Community (source build or legacy binary)&lt;/th&gt;
&lt;th&gt;AIStor&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Server-wide origin list&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;api cors_allow_origin&lt;/code&gt; / &lt;code&gt;MINIO_API_CORS_ALLOW_ORIGIN&lt;/code&gt;, default &lt;code&gt;*&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The same setting (&lt;a href="https://docs.min.io/aistor/reference/aistor-server/settings/core/" rel="noopener noreferrer"&gt;core settings&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Per-bucket rules&lt;/td&gt;
&lt;td&gt;None: &lt;code&gt;PutBucketCors&lt;/code&gt; returns &lt;code&gt;NotImplemented&lt;/code&gt;, HTTP 501 (&lt;a href="https://github.com/minio/minio/blob/master/cmd/api-errors.go" rel="noopener noreferrer"&gt;api-errors.go&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;S3 CORS specification, up to 100 rules per bucket (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GetBucketCors&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Always &lt;code&gt;NoSuchCORSConfiguration&lt;/code&gt;, HTTP 404, even while CORS headers are served (&lt;a href="https://github.com/minio/minio/blob/master/cmd/dummy-handlers.go" rel="noopener noreferrer"&gt;dummy-handlers.go&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;The bucket’s rules as XML; &lt;code&gt;mc cors get&lt;/code&gt; prints &lt;code&gt;No bucket CORS configuration found.&lt;/code&gt; when there are none (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-get/" rel="noopener noreferrer"&gt;mc cors get&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exposed headers&lt;/td&gt;
&lt;td&gt;MinIO’s common S3 header list, including &lt;code&gt;ETag&lt;/code&gt; (&lt;a href="https://github.com/minio/minio/blob/master/cmd/api-router.go" rel="noopener noreferrer"&gt;api-router.go&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;Per rule, with &lt;code&gt;ExposeHeader&lt;/code&gt; (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The community MinIO repository was archived on 2026-04-25 and the edition is distributed as source code only; its legacy binaries “will not receive updates” (&lt;a href="https://github.com/minio/minio" rel="noopener noreferrer"&gt;minio/minio&lt;/a&gt;). Forks of MinIO such as Silo have their own bucket CORS (&lt;a href="https://silo.pigsty.io/reference/s3-api-compatibility/" rel="noopener noreferrer"&gt;Silo docs&lt;/a&gt;), so on a fork, check the fork’s docs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which browser error do you have?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What the browser reports&lt;/th&gt;
&lt;th&gt;Where to look&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;No &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; on the preflight&lt;/td&gt;
&lt;td&gt;The origin is not in MinIO’s list, or a proxy dropped the headers (&lt;a href="https://github.com/rs/cors/blob/v1.11.1/cors.go" rel="noopener noreferrer"&gt;cors.go&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; on the real response&lt;/td&gt;
&lt;td&gt;The request reached another host or layer, or a proxy adds the header only on success codes (&lt;a href="https://nginx.org/en/docs/http/ngx_http_headers_module.html" rel="noopener noreferrer"&gt;nginx&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;More than one &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Two layers both set CORS (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors/CORSMultipleAllowOriginNotAllowed" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The preflight fails the “ok status” check&lt;/td&gt;
&lt;td&gt;Something in front of MinIO rejected the &lt;code&gt;OPTIONS&lt;/code&gt; (&lt;a href="https://github.com/chromium/chromium/blob/main/services/network/public/mojom/cors.mojom" rel="noopener noreferrer"&gt;cors.mojom&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Find out which MinIO you are running
&lt;/h2&gt;

&lt;p&gt;A community MinIO server built with a plain &lt;code&gt;go install&lt;/code&gt; reports the placeholder version &lt;code&gt;DEVELOPMENT.GOGET&lt;/code&gt; (&lt;a href="https://github.com/minio/minio/blob/master/cmd/build-constants.go" rel="noopener noreferrer"&gt;build-constants.go&lt;/a&gt;). Released MinIO binaries carry a timestamped release tag instead (&lt;a href="https://github.com/minio/minio/blob/master/cmd/build-constants.go" rel="noopener noreferrer"&gt;build-constants.go&lt;/a&gt;), and we found no documentation that tells a legacy community binary from AIStor by its version.&lt;/p&gt;

&lt;p&gt;The behavior settles it. Send &lt;code&gt;PutBucketCors&lt;/code&gt; to a scratch bucket: community MinIO answers &lt;code&gt;NotImplemented&lt;/code&gt;, HTTP 501 (&lt;a href="https://github.com/minio/minio/blob/master/cmd/api-errors.go" rel="noopener noreferrer"&gt;api-errors.go&lt;/a&gt;), and AIStor accepts it (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS&lt;/a&gt;). The Python program in the AIStor section runs this probe.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; never probe a bucket in use. On AIStor the probe creates a bucket rule, and from then on the global origin list no longer applies to that bucket (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-set/" rel="noopener noreferrer"&gt;mc cors set&lt;/a&gt;).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The error text you saw
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;A header you provided implies functionality that is not implemented&lt;/code&gt; is MinIO’s description of &lt;code&gt;NotImplemented&lt;/code&gt; (&lt;a href="https://github.com/minio/minio/blob/master/cmd/api-errors.go" rel="noopener noreferrer"&gt;api-errors.go&lt;/a&gt;): the server has no bucket CORS, so use the server-wide list below. &lt;code&gt;The XML you provided was not well-formed or did not validate against our published schema.&lt;/code&gt; is MinIO’s &lt;code&gt;MalformedXML&lt;/code&gt; (same file): on AIStor, check that the file is S3 CORS XML, not JSON (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-set/" rel="noopener noreferrer"&gt;mc cors set&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix it on community MinIO: set the server-wide origin list
&lt;/h2&gt;

&lt;p&gt;Set the list with &lt;code&gt;mc admin config set&lt;/code&gt;, using the key from the MinIO &lt;a href="https://github.com/minio/minio/blob/master/docs/config/README.md" rel="noopener noreferrer"&gt;config README&lt;/a&gt;. The alias and origins are example values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mc admin config &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;ALIAS&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; api &lt;span class="nv"&gt;cors_allow_origin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://app.example.com,https://admin.example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value replaces the old list, so include every origin that should keep working; if the browser app is Opndrive, that origin is the address you open it at, and our &lt;a href="https://docs.opndrive.app/guides/configure-cors" rel="noopener noreferrer"&gt;Configure CORS guide&lt;/a&gt; has the exact command.&lt;/p&gt;

&lt;p&gt;For community MinIO, build a current &lt;code&gt;mc&lt;/code&gt; with &lt;code&gt;go install github.com/minio/mc@latest&lt;/code&gt;; its repository was archived on 2026-07-14 (&lt;a href="https://github.com/minio/mc" rel="noopener noreferrer"&gt;minio/mc&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Four ways the origin list goes wrong
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A space after a comma.&lt;/strong&gt; MinIO splits the list on commas without trimming, so in &lt;code&gt;https://a.example.com, https://b.example.com&lt;/code&gt; the second entry never matches (&lt;a href="https://github.com/minio/minio/blob/master/internal/config/api/api.go" rel="noopener noreferrer"&gt;api.go&lt;/a&gt;, read from code). The AIStor docs write the list without spaces (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A trailing comma.&lt;/strong&gt; An empty entry fails the MinIO config with &lt;code&gt;invalid cors value&lt;/code&gt; (&lt;a href="https://github.com/minio/minio/blob/master/internal/config/api/api.go" rel="noopener noreferrer"&gt;api.go&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An environment variable that wins.&lt;/strong&gt; MinIO reads &lt;code&gt;MINIO_API_CORS_ALLOW_ORIGIN&lt;/code&gt; before the stored config, so a stale variable makes &lt;code&gt;mc admin config set&lt;/code&gt; look ignored (&lt;a href="https://github.com/minio/minio/blob/master/internal/config/api/api.go" rel="noopener noreferrer"&gt;api.go&lt;/a&gt;, inferred from code). Environment settings are not dynamic: change the variable and restart. Otherwise &lt;code&gt;api&lt;/code&gt; changes apply without a restart (&lt;a href="https://github.com/minio/minio/blob/master/docs/config/README.md" rel="noopener noreferrer"&gt;config README&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An origin that is not exact.&lt;/strong&gt; Use the exact value the browser sends as &lt;code&gt;Origin&lt;/code&gt;. MinIO matches entries with a wildcard matcher, so &lt;code&gt;https://*.example.com&lt;/code&gt; works (&lt;a href="https://github.com/minio/minio/blob/master/cmd/api-router.go" rel="noopener noreferrer"&gt;api-router.go&lt;/a&gt;). We did not check case or trailing-slash handling.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pasting AWS-style CORS JSON or XML stores nothing, and &lt;code&gt;NoSuchCORSConfiguration&lt;/code&gt; from &lt;code&gt;GetBucketCors&lt;/code&gt; is not the bug: community MinIO answers that for every bucket (&lt;a href="https://github.com/minio/minio/blob/master/cmd/dummy-handlers.go" rel="noopener noreferrer"&gt;dummy-handlers.go&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The default &lt;code&gt;*&lt;/code&gt; is not sent as a literal &lt;code&gt;*&lt;/code&gt;: MinIO echoes your origin with &lt;code&gt;Access-Control-Allow-Credentials: true&lt;/code&gt; (&lt;a href="https://github.com/minio/minio/blob/master/cmd/api-router.go" rel="noopener noreferrer"&gt;api-router.go&lt;/a&gt;, &lt;a href="https://github.com/rs/cors/blob/v1.11.1/cors.go" rel="noopener noreferrer"&gt;rs/cors&lt;/a&gt;), so the browser’s rule against a wildcard with credentials (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Origin" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;) does not apply.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix it on AIStor: per-bucket rules with mc cors set
&lt;/h2&gt;

&lt;p&gt;One bucket rule takes that bucket off the global list: “Once bucket-specific CORS is configured, global settings no longer apply to that bucket” (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-set/" rel="noopener noreferrer"&gt;mc cors set&lt;/a&gt;). Put every origin the bucket needs into its rules, up to 100 per bucket (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;cors_allow_origin&lt;/code&gt; at &lt;code&gt;*&lt;/code&gt;, AIStor echoes the origin with &lt;code&gt;Access-Control-Allow-Credentials: true&lt;/code&gt; by default; a separate setting turns that off (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Console steps: the AIStor docs show no CORS screen, so use mc
&lt;/h3&gt;

&lt;p&gt;The AIStor Console docs list no CORS tab for a bucket (&lt;a href="https://docs.min.io/aistor/administration/console/managing-objects/" rel="noopener noreferrer"&gt;managing objects&lt;/a&gt;), so use the AIStor Client (&lt;code&gt;mc&lt;/code&gt;), one command per step; the &lt;code&gt;mc cors&lt;/code&gt; commands are documented for the AIStor Client, and we did not check whether the archived community &lt;code&gt;mc&lt;/code&gt; has them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check what is active: &lt;code&gt;mc cors get &amp;lt;ALIAS&amp;gt;/&amp;lt;BUCKET&amp;gt;&lt;/code&gt;. &lt;code&gt;No bucket CORS configuration found.&lt;/code&gt; means the global list applies (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-get/" rel="noopener noreferrer"&gt;mc cors get&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Write &lt;code&gt;cors.xml&lt;/code&gt; in the S3 CORS schema; &lt;code&gt;mc cors set&lt;/code&gt; takes XML, not AWS-console JSON (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-set/" rel="noopener noreferrer"&gt;mc cors set&lt;/a&gt;). This example follows the rule on the &lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS page&lt;/a&gt;; add &lt;code&gt;POST&lt;/code&gt; or &lt;code&gt;DELETE&lt;/code&gt; only if your app uses them.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;  &lt;span class="nt"&gt;&amp;lt;CORSConfiguration&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;CORSRule&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;AllowedOrigin&amp;gt;&lt;/span&gt;https://app.example.com&lt;span class="nt"&gt;&amp;lt;/AllowedOrigin&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;AllowedMethod&amp;gt;&lt;/span&gt;GET&lt;span class="nt"&gt;&amp;lt;/AllowedMethod&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;AllowedMethod&amp;gt;&lt;/span&gt;PUT&lt;span class="nt"&gt;&amp;lt;/AllowedMethod&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;AllowedMethod&amp;gt;&lt;/span&gt;HEAD&lt;span class="nt"&gt;&amp;lt;/AllowedMethod&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;AllowedHeader&amp;gt;&lt;/span&gt;*&lt;span class="nt"&gt;&amp;lt;/AllowedHeader&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;ExposeHeader&amp;gt;&lt;/span&gt;ETag&lt;span class="nt"&gt;&amp;lt;/ExposeHeader&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;MaxAgeSeconds&amp;gt;&lt;/span&gt;3600&lt;span class="nt"&gt;&amp;lt;/MaxAgeSeconds&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/CORSRule&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/CORSConfiguration&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Apply it: &lt;code&gt;mc cors set &amp;lt;ALIAS&amp;gt;/&amp;lt;BUCKET&amp;gt; cors.xml&lt;/code&gt;, or pass &lt;code&gt;-&lt;/code&gt; to read standard input (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-set/" rel="noopener noreferrer"&gt;mc cors set&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Confirm: &lt;code&gt;mc cors get &amp;lt;ALIAS&amp;gt;/&amp;lt;BUCKET&amp;gt;&lt;/code&gt; prints the rules as XML (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-get/" rel="noopener noreferrer"&gt;mc cors get&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Run the curl test below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remove a bucket’s rules with &lt;code&gt;mc cors remove &amp;lt;ALIAS&amp;gt;/&amp;lt;BUCKET&amp;gt;&lt;/code&gt; (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS&lt;/a&gt;); a bucket with no CORS configuration falls back to the global settings (&lt;a href="https://docs.min.io/aistor/reference/cli/mc-cors/mc-cors-set/" rel="noopener noreferrer"&gt;mc cors set&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  The same thing from Python (boto3)
&lt;/h3&gt;

&lt;p&gt;This program sets bucket rules through the S3 API, which AIStor accepts (&lt;a href="https://docs.min.io/aistor/administration/cors-configuration/" rel="noopener noreferrer"&gt;AIStor CORS&lt;/a&gt;), and reads them back. On community MinIO it reports &lt;code&gt;NotImplemented&lt;/code&gt; and exits 2, so it doubles as the build probe on a scratch bucket. Each &lt;code&gt;put_bucket_cors&lt;/code&gt; call replaces any existing CORS configuration on the bucket (&lt;a href="https://docs.aws.amazon.com/boto3/latest/reference/services/s3/client/put_bucket_cors.html" rel="noopener noreferrer"&gt;boto3 docs&lt;/a&gt;). We have not run this program; &lt;code&gt;&amp;lt;...&amp;gt;&lt;/code&gt; values are placeholders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s2"&gt;"""Set per-bucket CORS on MinIO AIStor, or report that the server is community MinIO.
Untested: this program has not been run against any server."""&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;botocore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Config&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;botocore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exceptions&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;BotoCoreError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ClientError&lt;/span&gt;

&lt;span class="no"&gt;ENDPOINT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;MINIO_ENDPOINT&amp;gt;"&lt;/span&gt;   &lt;span class="c1"&gt;# the S3 API address, e.g. https://minio.example.com:9000, not the Console&lt;/span&gt;
&lt;span class="no"&gt;REGION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;REGION&amp;gt;"&lt;/span&gt;             &lt;span class="c1"&gt;# the region your MinIO server is configured with&lt;/span&gt;
&lt;span class="no"&gt;BUCKET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;BUCKET&amp;gt;"&lt;/span&gt;             &lt;span class="c1"&gt;# use a scratch bucket if you only want to probe the build&lt;/span&gt;
&lt;span class="no"&gt;ACCESS_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;ACCESS_KEY&amp;gt;"&lt;/span&gt;
&lt;span class="no"&gt;SECRET_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;SECRET_KEY&amp;gt;"&lt;/span&gt;

&lt;span class="no"&gt;CORS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"CORSRules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s2"&gt;"AllowedOrigins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"https://app.example.com"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# every origin this bucket must allow&lt;/span&gt;
            &lt;span class="s2"&gt;"AllowedMethods"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PUT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"HEAD"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s2"&gt;"AllowedHeaders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s2"&gt;"ExposeHeaders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ETag"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s2"&gt;"MaxAgeSeconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"s3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;endpoint_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;ENDPOINT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;REGION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;aws_access_key_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;ACCESS_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;aws_secret_access_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signature_version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"s3v4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"addressing_style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put_bucket_cors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CORSConfiguration&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;CORS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;rules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_bucket_cors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CORSRules"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ClientError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Error"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Code"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ResponseMetadata"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"HTTPStatusCode"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"NotImplemented"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"No per-bucket CORS here (community MinIO): "&lt;/span&gt;
                  &lt;span class="s2"&gt;"set api cors_allow_origin instead."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"S3 error {code} (HTTP {status}): {err.response['Error'].get('Message', '')}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;BotoCoreError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Could not talk to {ENDPOINT}: {err}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"CORS rules on {BUCKET}: {rules}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test the preflight with curl, then the real request
&lt;/h2&gt;

&lt;p&gt;Browsers send the preflight themselves: an &lt;code&gt;OPTIONS&lt;/code&gt; with &lt;code&gt;Origin&lt;/code&gt;, &lt;code&gt;Access-Control-Request-Method&lt;/code&gt; and optionally &lt;code&gt;Access-Control-Request-Headers&lt;/code&gt; (&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;). curl sends none of these unless you add them, and community MinIO treats an &lt;code&gt;OPTIONS&lt;/code&gt; as a preflight only when &lt;code&gt;Access-Control-Request-Method&lt;/code&gt; is present (&lt;a href="https://github.com/rs/cors/blob/v1.11.1/cors.go" rel="noopener noreferrer"&gt;rs/cors&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Aim at the MinIO S3 API endpoint, not the Console. The AIStor docs give the Console its own listen address, &lt;code&gt;MINIO_CONSOLE_ADDRESS&lt;/code&gt;, separate from the server’s &lt;code&gt;MINIO_ADDRESS&lt;/code&gt; (&lt;a href="https://docs.min.io/aistor/reference/aistor-server/settings/core/" rel="noopener noreferrer"&gt;core settings&lt;/a&gt;), and a staff reply in an unresolved forum thread on this error asked about exactly this (&lt;a href="https://forum.cloudron.io/topic/8173/minio-cors-error-missingalloworiginheader" rel="noopener noreferrer"&gt;Cloudron forum&lt;/a&gt;). Command 1, the preflight (example origin):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -i -X OPTIONS &lt;span class="s2"&gt;"&amp;lt;MINIO_ENDPOINT&amp;gt;/&amp;lt;BUCKET&amp;gt;/&amp;lt;KEY&amp;gt;"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Origin: https://app.example.com"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Access-Control-Request-Method: PUT"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Access-Control-Request-Headers: content-type"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What MinIO’s source code says you should see on community MinIO for an allowed origin: &lt;code&gt;204&lt;/code&gt;, &lt;code&gt;Access-Control-Allow-Origin: https://app.example.com&lt;/code&gt; (your origin echoed), &lt;code&gt;Access-Control-Allow-Credentials: true&lt;/code&gt;, &lt;code&gt;Access-Control-Allow-Headers&lt;/code&gt; repeating your request, and &lt;code&gt;Vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers&lt;/code&gt; (&lt;a href="https://github.com/rs/cors/blob/v1.11.1/README.md" rel="noopener noreferrer"&gt;rs/cors README&lt;/a&gt;, &lt;a href="https://github.com/rs/cors/blob/v1.11.1/cors.go" rel="noopener noreferrer"&gt;cors.go&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;A refused origin on community MinIO also gets &lt;code&gt;204&lt;/code&gt;, just without any &lt;code&gt;Access-Control-Allow-*&lt;/code&gt; header (&lt;a href="https://github.com/rs/cors/blob/v1.11.1/cors.go" rel="noopener noreferrer"&gt;cors.go&lt;/a&gt;). &lt;strong&gt;Read the &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; header, not the status.&lt;/strong&gt; Amazon S3, by contrast, answers a refused request with &lt;code&gt;403 Forbidden&lt;/code&gt; (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/cors-troubleshooting.html" rel="noopener noreferrer"&gt;AWS CORS troubleshooting&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Community MinIO answers the preflight before authentication and routing, because its CORS handler wraps the whole server (&lt;a href="https://github.com/minio/minio/blob/master/cmd/server-main.go" rel="noopener noreferrer"&gt;server-main.go&lt;/a&gt;), so bad keys or a wrong bucket will not show up. Command 2 sends the real request to a presigned GET URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -i &lt;span class="s2"&gt;"&amp;lt;PRESIGNED_GET_URL&amp;gt;"&lt;/span&gt; -H &lt;span class="s2"&gt;"Origin: https://app.example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; must be on this response too: Chromium’s &lt;code&gt;MissingAllowOriginHeader&lt;/code&gt; is about the actual response, while a failed preflight is &lt;code&gt;PreflightMissingAllowOriginHeader&lt;/code&gt; (&lt;a href="https://github.com/chromium/chromium/blob/main/services/network/public/mojom/cors.mojom" rel="noopener noreferrer"&gt;cors.mojom&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcjfo0rox6jg0km5jb5dd.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcjfo0rox6jg0km5jb5dd.webp" alt="Sequence diagram: a browser sends an OPTIONS preflight with Origin, Access-Control-Request-Method and Access-Control-Request-Headers to community MinIO; an allowed origin gets 204 with Access-Control-Allow-Origin and the real request follows, while a refused origin also gets 204 but with no Access-Control-Allow-* headers and the browser blocks it." width="799" height="594"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;On community MinIO a refused origin still gets 204, so check for the Access-Control-Allow-Origin header, not the status. Drawn from MinIO’s source code (&lt;a href="https://github.com/rs/cors/blob/v1.11.1/cors.go" rel="noopener noreferrer"&gt;cors.go&lt;/a&gt;, &lt;a href="https://github.com/minio/minio/blob/master/cmd/api-router.go" rel="noopener noreferrer"&gt;api-router.go&lt;/a&gt;), not from a live run.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After a change, run curl first, then hard-reload the page: browsers cache a preflight for 5 seconds by default, or for &lt;code&gt;Access-Control-Max-Age&lt;/code&gt; up to each browser’s own cap (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Behind a reverse proxy, let one layer set CORS
&lt;/h2&gt;

&lt;p&gt;Run command 1 against MinIO’s own port, then against the proxy hostname; the layer where the headers change is the one to fix. If MinIO and the proxy both add &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;, the browser rejects the response (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors/CORSMultipleAllowOriginNotAllowed" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;), so pick one layer. In nginx, three directives cause most of the trouble:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;add_header&lt;/code&gt; applies only to certain success and redirect codes unless you add &lt;code&gt;always&lt;/code&gt;, so a 403 or 404 loses the header and shows up as a CORS error (&lt;a href="https://nginx.org/en/docs/http/ngx_http_headers_module.html" rel="noopener noreferrer"&gt;headers module&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Server-level &lt;code&gt;add_header&lt;/code&gt; lines are not inherited by a &lt;code&gt;location&lt;/code&gt; that has its own &lt;code&gt;add_header&lt;/code&gt; (&lt;a href="https://nginx.org/en/docs/http/ngx_http_headers_module.html" rel="noopener noreferrer"&gt;headers module&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;To own CORS at the proxy, hide each &lt;code&gt;Access-Control-*&lt;/code&gt; header MinIO sets, including &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;, &lt;code&gt;Access-Control-Allow-Credentials&lt;/code&gt; and &lt;code&gt;Access-Control-Expose-Headers&lt;/code&gt; (&lt;a href="https://github.com/minio/minio/blob/master/cmd/api-router.go" rel="noopener noreferrer"&gt;api-router.go&lt;/a&gt;, &lt;a href="https://github.com/rs/cors/blob/v1.11.1/cors.go" rel="noopener noreferrer"&gt;cors.go&lt;/a&gt;), with one &lt;code&gt;proxy_hide_header&lt;/code&gt; line per header, then add your own (&lt;a href="https://nginx.org/en/docs/http/ngx_http_proxy_module.html" rel="noopener noreferrer"&gt;proxy module&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The proxy must pass &lt;code&gt;OPTIONS&lt;/code&gt; and forward &lt;code&gt;Origin&lt;/code&gt;, &lt;code&gt;Access-Control-Request-Method&lt;/code&gt; and &lt;code&gt;Access-Control-Request-Headers&lt;/code&gt;, and a caching proxy needs &lt;code&gt;Origin&lt;/code&gt; in its cache key (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/cors-troubleshooting.html" rel="noopener noreferrer"&gt;AWS CORS troubleshooting&lt;/a&gt;). nginx does not pass a header set to an empty string (&lt;a href="https://nginx.org/en/docs/http/ngx_http_proxy_module.html" rel="noopener noreferrer"&gt;proxy module&lt;/a&gt;), so &lt;code&gt;proxy_set_header Origin "";&lt;/code&gt; leaves MinIO with no origin to answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Presigned URLs don’t get you past CORS
&lt;/h2&gt;

&lt;p&gt;AWS calls presigned URLs “bearer tokens that grant access to those who possess them” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS presigned URLs&lt;/a&gt;): the signature authorizes the request, but CORS is a separate browser check. A browser &lt;code&gt;PUT&lt;/code&gt; is not a simple request, so it preflights; a plain &lt;code&gt;GET&lt;/code&gt; may not, but its response still needs &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;A “CORS error” with no HTTP status usually means the response never came from MinIO at all: look for a proxy error page or a redirect. That is our inference, not documented MinIO behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try Opndrive
&lt;/h2&gt;

&lt;p&gt;Opndrive gives any S3-compatible bucket a Drive-like web interface you host yourself.&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/Opndrive/opndrive" rel="noopener noreferrer"&gt;See it on GitHub&lt;/a&gt; or &lt;a href="https://docs.opndrive.app" rel="noopener noreferrer"&gt;read the docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First published on &lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test" rel="noopener noreferrer"&gt;opndrive.app&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>debugging</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Minimum IAM Policy for an S3 Web Client: One Bucket, Least Privilege</title>
      <dc:creator>Opndrive</dc:creator>
      <pubDate>Thu, 26 Nov 2026 15:13:30 +0000</pubDate>
      <link>https://dev.to/opndrive/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege-4f0m</link>
      <guid>https://dev.to/opndrive/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege-4f0m</guid>
      <description>&lt;p&gt;The quickest policies to give a web file manager’s access key are the broad ones. AWS’s managed &lt;a href="https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AdministratorAccess.html" rel="noopener noreferrer"&gt;AdministratorAccess&lt;/a&gt; policy allows &lt;code&gt;"Action" : "*"&lt;/code&gt; on &lt;code&gt;"Resource" : "*"&lt;/code&gt;, and &lt;a href="https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonS3FullAccess.html" rel="noopener noreferrer"&gt;AmazonS3FullAccess&lt;/a&gt; allows &lt;code&gt;s3:*&lt;/code&gt; on every resource, so either key works on every bucket in the account.&lt;/p&gt;

&lt;p&gt;AWS’s IAM guidance is to &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html" rel="noopener noreferrer"&gt;“grant only the permissions required to perform a task”&lt;/a&gt;, and it warns that AWS managed policies “might not grant least-privilege permissions” for your use. It prefers temporary credentials, but names third-party clients that don’t support IAM Identity Center as the case for an IAM user’s long-term access keys, which is where a web client sits.&lt;/p&gt;

&lt;p&gt;This guide trims AWS’s one-bucket example to browse, upload, download and delete, adds what large uploads need, and shows how to test the result with a throwaway user. The result is a minimum IAM policy for an S3 web client that is narrower than &lt;code&gt;s3:*&lt;/code&gt;; this post claims nothing more for it.&lt;/p&gt;

&lt;p&gt;In this guide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege#the-minimum-iam-policy-for-an-s3-web-client" rel="noopener noreferrer"&gt;The minimum IAM policy for an S3 web client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege#awss-one-bucket-example-trimmed-for-a-web-client" rel="noopener noreferrer"&gt;AWS’s one-bucket example, trimmed for a web client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege#the-three-resource-scopes-behind-the-two-statements" rel="noopener noreferrer"&gt;The three resource scopes behind the two statements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege#large-files-the-three-multipart-actions" rel="noopener noreferrer"&gt;Large files: the three multipart actions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege#actions-to-add-for-your-client-or-bucket" rel="noopener noreferrer"&gt;Actions to add for your client or bucket&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege#test-the-policy-with-a-throwaway-user" rel="noopener noreferrer"&gt;Test the policy with a throwaway user&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opndrive.app/blog/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege#r2-b2-wasabi-minio-and-spaces-scope-keys-differently" rel="noopener noreferrer"&gt;R2, B2, Wasabi, MinIO and Spaces scope keys differently&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The minimum IAM policy for an S3 web client
&lt;/h2&gt;

&lt;p&gt;A browser file manager that browses, uploads, downloads and deletes in one bucket needs two statements. &lt;code&gt;s3:ListBucket&lt;/code&gt; goes on the bucket ARN, &lt;code&gt;arn:aws:s3:::&amp;lt;BUCKET&amp;gt;&lt;/code&gt;. &lt;code&gt;s3:GetObject&lt;/code&gt;, &lt;code&gt;s3:PutObject&lt;/code&gt; and &lt;code&gt;s3:DeleteObject&lt;/code&gt; go on the object ARN, &lt;code&gt;arn:aws:s3:::&amp;lt;BUCKET&amp;gt;/*&lt;/code&gt;. Uploads large enough for multipart add three more actions, split the same way.&lt;/p&gt;

&lt;p&gt;The split follows AWS’s &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;Required permissions for Amazon S3 API operations&lt;/a&gt; and its &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;multipart upload overview&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"BucketLevel"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"s3:ListBucket"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"s3:ListBucketMultipartUploads"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:s3:::&amp;lt;BUCKET&amp;gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ObjectLevel"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s2"&gt;"s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"s3:PutObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"s3:DeleteObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"s3:AbortMultipartUpload"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"s3:ListMultipartUploadParts"&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:s3:::&amp;lt;BUCKET&amp;gt;/*"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;BUCKET&amp;gt;&lt;/code&gt; (a placeholder) with your bucket’s name in both places. The &lt;code&gt;aws&lt;/code&gt; after &lt;code&gt;arn:&lt;/code&gt; is the partition in AWS’s &lt;a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html" rel="noopener noreferrer"&gt;ARN format&lt;/a&gt;, so an account in another partition changes it too.&lt;/p&gt;

&lt;p&gt;The policy leaves out other buckets, the region lookup, ACLs, object versions and bucket settings. The sections below say when to add one back.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS’s one-bucket example, trimmed for a web client
&lt;/h2&gt;

&lt;p&gt;AWS’s &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-policies-s3.html" rel="noopener noreferrer"&gt;one-bucket example&lt;/a&gt; has three statements: &lt;code&gt;s3:ListAllMyBuckets&lt;/code&gt; alone on &lt;code&gt;"*"&lt;/code&gt;, &lt;code&gt;s3:ListBucket&lt;/code&gt; and &lt;code&gt;s3:GetBucketLocation&lt;/code&gt; on the bare bucket ARN, and &lt;code&gt;s3:PutObject&lt;/code&gt;, &lt;code&gt;s3:PutObjectAcl&lt;/code&gt;, &lt;code&gt;s3:GetObject&lt;/code&gt;, &lt;code&gt;s3:GetObjectAcl&lt;/code&gt; and &lt;code&gt;s3:DeleteObject&lt;/code&gt; on &lt;code&gt;bucket/*&lt;/code&gt; only.&lt;/p&gt;

&lt;p&gt;The same page says its examples “will work if you use them programmatically”, and calls &lt;code&gt;ListAllMyBuckets&lt;/code&gt;, &lt;code&gt;GetBucketLocation&lt;/code&gt; and &lt;code&gt;ListBucket&lt;/code&gt; “the additional permissions required by the console”. It says the two ACL actions are required “to copy, cut, and paste objects in the console”. A web client calls the API directly, so each console extra has to earn its place:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action in AWS’s example&lt;/th&gt;
&lt;th&gt;API call it allows&lt;/th&gt;
&lt;th&gt;For a web client&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;s3:ListAllMyBuckets&lt;/code&gt; on &lt;code&gt;"*"&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;ListBuckets, the list of every bucket you own (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;Drop it if you give the client the bucket name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;s3:GetBucketLocation&lt;/code&gt; on the bucket&lt;/td&gt;
&lt;td&gt;GetBucketLocation, which returns the bucket’s region (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;Drop it if you give the client the region; AWS doesn’t say so outright, so test it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;s3:ListBucket&lt;/code&gt; on the bucket&lt;/td&gt;
&lt;td&gt;ListObjectsV2 and HeadBucket (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/security_iam_service-with-iam.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;Keep&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;s3:GetObject&lt;/code&gt;, &lt;code&gt;s3:PutObject&lt;/code&gt;, &lt;code&gt;s3:DeleteObject&lt;/code&gt; on &lt;code&gt;bucket/*&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Download, upload and delete (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/security_iam_service-with-iam.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;Keep&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;s3:PutObjectAcl&lt;/code&gt;, &lt;code&gt;s3:GetObjectAcl&lt;/code&gt; on &lt;code&gt;bucket/*&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Setting an ACL on upload, showing object owner information (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;Drop: new buckets have ACLs disabled by default, and PUT requests with any ACL other than bucket-owner-full-control then fail (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;); a client that doesn’t show object owner information doesn’t need &lt;code&gt;s3:GetObjectAcl&lt;/code&gt; (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The three resource scopes behind the two statements
&lt;/h2&gt;

&lt;p&gt;Each S3 action belongs to one resource scope, and the statement’s &lt;code&gt;Resource&lt;/code&gt; has to match it. AWS’s &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;required-permissions page&lt;/a&gt; names three:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bucket operations need the bucket ARN as the &lt;code&gt;Resource&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Object operations need the object ARN.&lt;/li&gt;
&lt;li&gt;Account operations, such as ListBuckets, need &lt;code&gt;"*"&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh38zlawsyassonkiw3dm.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh38zlawsyassonkiw3dm.webp" alt="Three nested resource scopes: the account scope with Resource &amp;quot;*&amp;quot; holding s3:ListAllMyBuckets, the bucket scope holding s3:ListBucket, s3:ListBucketMultipartUploads and s3:GetBucketLocation, and the object scope with the bucket ARN plus /* holding s3:GetObject, s3:PutObject, s3:DeleteObject, s3:AbortMultipartUpload and s3:ListMultipartUploadParts." width="799" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Each action’s Resource must be its own scope. The minimum policy is the bucket statement and the object statement. The dashed actions are optional extras, and s3:ListAllMyBuckets needs a statement of its own. We put s3:ListBucketMultipartUploads on the bucket, as AWS’s &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;multipart overview&lt;/a&gt; says, but haven’t run the placement test.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Listing a folder with ListObjectsV2 is a bucket operation, while GetObject, PutObject and DeleteObject are object operations (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/security_iam_service-with-iam.html" rel="noopener noreferrer"&gt;How Amazon S3 works with IAM&lt;/a&gt;). The object ARN “must contain a forward slash after the bucket name”, so a policy that puts &lt;code&gt;s3:GetObject&lt;/code&gt; only on &lt;code&gt;arn:aws:s3:::&amp;lt;BUCKET&amp;gt;&lt;/code&gt; allows no downloads.&lt;/p&gt;

&lt;p&gt;Account-level actions need a statement of their own. AWS’s &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html" rel="noopener noreferrer"&gt;policy editor guide&lt;/a&gt; says an action on &lt;code&gt;"*"&lt;/code&gt; and an action on a specific ARN “must be in two separate JSON statements”, which is why adding &lt;code&gt;s3:ListAllMyBuckets&lt;/code&gt; means a third statement.&lt;/p&gt;

&lt;h3&gt;
  
  
  What each file-manager action calls
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You click&lt;/th&gt;
&lt;th&gt;S3 API call&lt;/th&gt;
&lt;th&gt;IAM action&lt;/th&gt;
&lt;th&gt;Resource&lt;/th&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Open a folder&lt;/td&gt;
&lt;td&gt;ListObjectsV2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:ListBucket&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;bucket&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Download or preview&lt;/td&gt;
&lt;td&gt;GetObject&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:GetObject&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bucket/*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/security_iam_service-with-iam.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File details (size, type)&lt;/td&gt;
&lt;td&gt;HeadObject&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:GetObject&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bucket/*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upload&lt;/td&gt;
&lt;td&gt;PutObject, or multipart for large files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:PutObject&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bucket/*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rename or move&lt;/td&gt;
&lt;td&gt;CopyObject, then DeleteObject&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;s3:GetObject&lt;/code&gt; on the source, &lt;code&gt;s3:PutObject&lt;/code&gt; on the destination, then &lt;code&gt;s3:DeleteObject&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bucket/*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete a folder&lt;/td&gt;
&lt;td&gt;ListObjectsV2, then DeleteObjects&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;s3:ListBucket&lt;/code&gt;, then &lt;code&gt;s3:DeleteObject&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;bucket, then &lt;code&gt;bucket/*&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Share link&lt;/td&gt;
&lt;td&gt;Presigned GetObject&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;s3:GetObject&lt;/code&gt;, held by the signing key&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bucket/*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A rename is a copy plus a delete, so a key without &lt;code&gt;s3:DeleteObject&lt;/code&gt; copies the file and leaves the old one in place. Copying into a second bucket needs that bucket in the policy too, because the copy needs &lt;code&gt;s3:PutObject&lt;/code&gt; on the destination.&lt;/p&gt;

&lt;p&gt;A share link can do only what its signer can. AWS says &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;“the capabilities of a presigned URL are limited by the permissions of the user who created it”&lt;/a&gt;, and calls presigned URLs “bearer tokens”.&lt;/p&gt;

&lt;p&gt;For a 403 &lt;code&gt;SignatureDoesNotMatch&lt;/code&gt; on a browser upload, see fix SignatureDoesNotMatch on browser uploads.&lt;/p&gt;

&lt;h3&gt;
  
  
  A missing file returns 403 without ListBucket
&lt;/h3&gt;

&lt;p&gt;AWS’s &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html" rel="noopener noreferrer"&gt;GetObject reference&lt;/a&gt; says a request for a missing key returns “404 Not Found” if the caller has &lt;code&gt;s3:ListBucket&lt;/code&gt; on the bucket, and “403 Access Denied” if not. Without &lt;code&gt;s3:ListBucket&lt;/code&gt;, a missing file looks like a permissions problem, and the test program below checks for this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Large files: the three multipart actions
&lt;/h2&gt;

&lt;p&gt;AWS calls multipart upload a best practice &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;“for objects that are 100 MB or larger”&lt;/a&gt;, and each client decides when it switches to it. &lt;code&gt;s3:PutObject&lt;/code&gt; covers starting the upload, uploading each part and completing it (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;), but three actions are separate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;s3:AbortMultipartUpload&lt;/code&gt; stops an upload. It goes on &lt;code&gt;bucket/*&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;s3:ListMultipartUploadParts&lt;/code&gt; lists the parts of one upload. It goes on &lt;code&gt;bucket/*&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;s3:ListBucketMultipartUploads&lt;/code&gt; lists the uploads in progress in a bucket. It goes on the bucket ARN.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The API call is named ListMultipartUploads, but the IAM action that allows it is &lt;code&gt;s3:ListBucketMultipartUploads&lt;/code&gt; (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;), so a policy that names &lt;code&gt;s3:ListMultipartUploads&lt;/code&gt; doesn’t grant the call.&lt;/p&gt;

&lt;p&gt;AWS’s pages disagree on where that action goes. The &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;required-permissions page&lt;/a&gt; lists the ListMultipartUploads row among object operations, while the &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;multipart overview&lt;/a&gt; says the action is allowed “on a bucket”. This policy follows the overview, and AWS’s &lt;a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html" rel="noopener noreferrer"&gt;Service Authorization Reference&lt;/a&gt; agrees: it lists the bucket as the resource type for &lt;code&gt;s3:ListBucketMultipartUploads&lt;/code&gt;. We haven’t run the placement test described below, so run it before you rely on either page.&lt;/p&gt;

&lt;p&gt;Unfinished uploads cost storage: AWS says you “must either complete or stop the multipart upload to stop incurring charges”. It recommends a lifecycle rule with &lt;code&gt;AbortIncompleteMultipartUpload&lt;/code&gt; (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;), which you set on the bucket with admin credentials; the client’s key needs no permission for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Actions to add for your client or bucket
&lt;/h2&gt;

&lt;p&gt;Add an action only when the test below fails without it, or when your bucket’s setup needs it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;If&lt;/th&gt;
&lt;th&gt;Add&lt;/th&gt;
&lt;th&gt;Resource&lt;/th&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The client lists your buckets so you can pick one&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:ListAllMyBuckets&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;"*"&lt;/code&gt;, in its own statement&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The client looks up the bucket’s region&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:GetBucketLocation&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;bucket&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The bucket is versioned and the client reads or deletes specific versions&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;s3:GetObjectVersion&lt;/code&gt;, &lt;code&gt;s3:DeleteObjectVersion&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bucket/*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The client lists object versions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:ListBucketVersions&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;bucket&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The bucket encrypts with an AWS KMS customer managed key&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kms:GenerateDataKey&lt;/code&gt; for uploads; &lt;code&gt;kms:Decrypt&lt;/code&gt; for downloads and multipart uploads&lt;/td&gt;
&lt;td&gt;the KMS key&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The bucket still uses ACLs and the client sets them&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;s3:PutObjectAcl&lt;/code&gt;, &lt;code&gt;s3:GetObjectAcl&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bucket/*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The KMS actions go in a statement of their own, with the key’s ARN as the resource.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limit the key to one folder
&lt;/h3&gt;

&lt;p&gt;To confine the key to one folder, change the object statement’s resource to &lt;code&gt;arn:aws:s3:::&amp;lt;BUCKET&amp;gt;/&amp;lt;FOLDER&amp;gt;/*&lt;/code&gt; and add an &lt;code&gt;s3:prefix&lt;/code&gt; condition to &lt;code&gt;s3:ListBucket&lt;/code&gt;. AWS’s &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-policies-s3.html" rel="noopener noreferrer"&gt;per-user folder example&lt;/a&gt; does both, using &lt;code&gt;${aws:username}&lt;/code&gt; where this fragment has the placeholder &lt;code&gt;&amp;lt;FOLDER&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ListOnlyTheFolder"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"s3:ListBucket"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:s3:::&amp;lt;BUCKET&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Condition"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"StringLike"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"s3:prefix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;FOLDER&amp;gt;/*"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove &lt;code&gt;s3:ListBucket&lt;/code&gt; from the &lt;code&gt;BucketLevel&lt;/code&gt; statement and keep &lt;code&gt;s3:ListBucketMultipartUploads&lt;/code&gt; there; an unconditioned &lt;code&gt;s3:ListBucket&lt;/code&gt; alongside this statement still lists the whole bucket.&lt;/p&gt;

&lt;p&gt;AWS’s example also adds a listing statement with an empty &lt;code&gt;s3:prefix&lt;/code&gt; and a &lt;code&gt;/&lt;/code&gt; &lt;code&gt;s3:delimiter&lt;/code&gt;, so the user can open the bucket root and see the folder. Left without a condition, &lt;code&gt;s3:ListBucketMultipartUploads&lt;/code&gt; still lists in-progress uploads for the whole bucket. We haven’t tested this fragment, and how a client’s list requests meet the condition depends on the prefix and delimiter it sends, so run the test program with &lt;code&gt;PREFIX&lt;/code&gt; inside the folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the policy with a throwaway user
&lt;/h2&gt;

&lt;p&gt;IAM denies by default: AWS says a policy &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/troubleshoot-403-errors.html" rel="noopener noreferrer"&gt;“must explicitly allow the principal to perform an action”&lt;/a&gt;, and anything missing fails with HTTP 403. Test with a user that holds only this policy, never with your admin key. The steps use the placeholder &lt;code&gt;&amp;lt;TEST_USER&amp;gt;&lt;/code&gt; and an inline policy named &lt;code&gt;web-client-one-bucket&lt;/code&gt;, which the console &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_remove.html" rel="noopener noreferrer"&gt;deletes together with the user&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Console steps
&lt;/h3&gt;

&lt;p&gt;The labels come from AWS’s IAM User Guide as read on 2026-11-23.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the IAM console at &lt;code&gt;https://console.aws.amazon.com/iam/&lt;/code&gt;. In the navigation pane, choose &lt;strong&gt;Users&lt;/strong&gt;, then &lt;strong&gt;Create user&lt;/strong&gt; (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started-workloads.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;On &lt;strong&gt;Specify user details&lt;/strong&gt;, enter a &lt;strong&gt;User name&lt;/strong&gt; and choose &lt;strong&gt;Next&lt;/strong&gt;. Leave console access off: AWS says to &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html" rel="noopener noreferrer"&gt;“Create only the credentials that the user needs”&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;On &lt;strong&gt;Set Permissions&lt;/strong&gt;, which is optional, add nothing and choose &lt;strong&gt;Next&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Review the user, then choose &lt;strong&gt;Create user&lt;/strong&gt;. In the status notification, choose &lt;strong&gt;View user&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On the user’s page, open the &lt;strong&gt;Permissions&lt;/strong&gt; tab. Choose &lt;strong&gt;Add permissions&lt;/strong&gt;, then &lt;strong&gt;Create inline policy&lt;/strong&gt; (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Policy editor&lt;/strong&gt;, choose &lt;strong&gt;JSON&lt;/strong&gt; and paste the policy. Resolve any warnings from policy validation, then choose &lt;strong&gt;Next&lt;/strong&gt; (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;On &lt;strong&gt;Review and create&lt;/strong&gt;, enter &lt;code&gt;web-client-one-bucket&lt;/code&gt; as the &lt;strong&gt;Policy Name&lt;/strong&gt; and choose &lt;strong&gt;Create policy&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;Security credentials&lt;/strong&gt; tab. In &lt;strong&gt;Access keys&lt;/strong&gt;, choose &lt;strong&gt;Create access key&lt;/strong&gt; (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access-keys-admin-managed.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;On &lt;strong&gt;Access key best practices &amp;amp; alternatives&lt;/strong&gt;, choose &lt;strong&gt;Other&lt;/strong&gt;, then &lt;strong&gt;Next&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On &lt;strong&gt;Set description tag&lt;/strong&gt;, which is optional, choose &lt;strong&gt;Create access key&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On &lt;strong&gt;Retrieve access key&lt;/strong&gt;, choose &lt;strong&gt;Show&lt;/strong&gt; or &lt;strong&gt;Download .csv file&lt;/strong&gt;. AWS says a lost secret &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/iam/create-access-key.html" rel="noopener noreferrer"&gt;“cannot be recovered, and you must create a new access key”&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The same steps with the AWS CLI
&lt;/h3&gt;

&lt;p&gt;Save the policy as &lt;code&gt;policy.json&lt;/code&gt; and run these with your admin credentials (&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/iam/create-user.html" rel="noopener noreferrer"&gt;create-user&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/iam/put-user-policy.html" rel="noopener noreferrer"&gt;put-user-policy&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/iam/create-access-key.html" rel="noopener noreferrer"&gt;create-access-key&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws iam create-user --user-name &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;TEST_USER&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
aws iam put-user-policy --user-name &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;TEST_USER&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
    --policy-name web-client-one-bucket --policy-document file://policy.json
aws iam create-access-key --user-name &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;TEST_USER&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;put-user-policy&lt;/code&gt; “adds or updates” an inline policy, so re-running it with an edited &lt;code&gt;policy.json&lt;/code&gt; is how you try a variant.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check every action with one Python program
&lt;/h3&gt;

&lt;p&gt;The program runs each call a file manager makes with the throwaway key and prints &lt;code&gt;OK&lt;/code&gt;, or the error code and HTTP status. It also requests a missing key to show the 404 or 403, and exits with 1 if a required check fails or 2 if it can’t reach the endpoint. For an S3-compatible provider, set &lt;code&gt;ENDPOINT&lt;/code&gt; and &lt;code&gt;REGION&lt;/code&gt;. It writes and deletes small objects under &lt;code&gt;PREFIX&lt;/code&gt; only.&lt;/p&gt;

&lt;p&gt;Untested: we built this from the boto3 documentation (&lt;a href="https://docs.aws.amazon.com/boto3/latest/reference/core/session.html" rel="noopener noreferrer"&gt;client parameters&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/boto3/latest/guide/error-handling.html" rel="noopener noreferrer"&gt;error handling&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/boto3/latest/reference/services/s3/client/copy_object.html" rel="noopener noreferrer"&gt;copy_object&lt;/a&gt;) and have not run it against AWS or any other provider.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s2"&gt;"""Check what an access key can do in one S3 bucket.

Untested: built from the boto3 documentation, not run against AWS or any
S3-compatible service. It creates and deletes small objects under PREFIX.
"""&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;botocore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Config&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;botocore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exceptions&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;BotoCoreError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ClientError&lt;/span&gt;

&lt;span class="no"&gt;BUCKET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;BUCKET&amp;gt;"&lt;/span&gt;
&lt;span class="no"&gt;REGION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;REGION&amp;gt;"&lt;/span&gt;               &lt;span class="c1"&gt;# the bucket's region, or the region string your provider documents&lt;/span&gt;
&lt;span class="no"&gt;ENDPOINT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;                   &lt;span class="c1"&gt;# AWS: None. S3-compatible: "https://&amp;lt;ENDPOINT&amp;gt;"&lt;/span&gt;
&lt;span class="no"&gt;ACCESS_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;ACCESS_KEY_ID&amp;gt;"&lt;/span&gt;    &lt;span class="c1"&gt;# the throwaway user's key, never your admin key&lt;/span&gt;
&lt;span class="no"&gt;SECRET_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;SECRET_ACCESS_KEY&amp;gt;"&lt;/span&gt;
&lt;span class="no"&gt;PREFIX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"policy-check/"&lt;/span&gt;          &lt;span class="c1"&gt;# scratch folder; for a folder-scoped policy use "&amp;lt;FOLDER&amp;gt;/policy-check/"&lt;/span&gt;

&lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"s3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;REGION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;endpoint_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;ENDPOINT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;aws_access_key_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;ACCESS_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;aws_secret_access_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;signature_version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"s3v4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"addressing_style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"path"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;ENDPOINT&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"auto"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="no"&gt;KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;PREFIX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"probe.txt"&lt;/span&gt;
&lt;span class="no"&gt;RENAMED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;PREFIX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"probe-renamed.txt"&lt;/span&gt;
&lt;span class="no"&gt;BIG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;PREFIX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"probe-multipart.bin"&lt;/span&gt;
&lt;span class="n"&gt;upload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;start_multipart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_multipart_upload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BIG&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"UploadId"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="c1"&gt;# (label, required by the minimum policy?, call)&lt;/span&gt;
&lt;span class="no"&gt;CHECKS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"list folder      s3:ListBucket"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list_objects_v2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;PREFIX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;MaxKeys&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"upload           s3:PutObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Body&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;"policy check\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"file details     s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;head_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"download         s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Body"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"rename: copy     s3:GetObject + s3:PutObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copy_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;RENAMED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="nc"&gt;CopySource&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Bucket"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"rename: delete   s3:DeleteObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"delete           s3:DeleteObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;RENAMED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"multipart start  s3:PutObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start_multipart&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"list parts       s3:ListMultipartUploadParts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list_parts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BIG&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;UploadId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"list uploads     s3:ListBucketMultipartUploads"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list_multipart_uploads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;PREFIX&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"multipart abort  s3:AbortMultipartUpload"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abort_multipart_upload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BIG&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;UploadId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"region lookup    s3:GetBucketLocation"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_bucket_location&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"list buckets     s3:ListAllMyBuckets"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list_buckets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ClientError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Error"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Code"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ResponseMetadata"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"HTTPStatusCode"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{code} (HTTP {status})"&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;KeyError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"SKIPPED (no multipart upload was started)"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"OK"&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;failed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;CHECKS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;note&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;required&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"   optional"&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{label:&amp;lt;50} {result}{note}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;required&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"OK"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;failed&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;PREFIX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"no-such-key"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{'missing key (404 = ListBucket granted)':&amp;lt;50} {missing}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;BotoCoreError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Could not reach {ENDPOINT or 'AWS'}: {err}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"All required checks passed."&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
          &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{failed} required check(s) failed."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the policy from the first section, you should see &lt;code&gt;OK&lt;/code&gt; on every required row, &lt;code&gt;AccessDenied (HTTP 403)&lt;/code&gt; on the two optional rows and &lt;code&gt;NoSuchKey (HTTP 404)&lt;/code&gt; on the missing key. We expect this from AWS’s documentation and haven’t observed it. If a delete or the abort is denied, remove the leftovers under &lt;code&gt;PREFIX&lt;/code&gt; with admin credentials, because AWS charges for an open upload’s parts until it is completed or stopped.&lt;/p&gt;

&lt;h3&gt;
  
  
  Break it on purpose, then clean up
&lt;/h3&gt;

&lt;p&gt;Remove &lt;code&gt;s3:ListBucket&lt;/code&gt; from &lt;code&gt;policy.json&lt;/code&gt; and re-run &lt;code&gt;put-user-policy&lt;/code&gt;, or edit the inline policy in the console. When you re-run the program, the list row should fail and the missing-key row should change from 404 to 403.&lt;/p&gt;

&lt;p&gt;To settle the multipart placement question, move &lt;code&gt;s3:ListBucketMultipartUploads&lt;/code&gt; into the &lt;code&gt;ObjectLevel&lt;/code&gt; statement and re-run. If the list-uploads row turns into &lt;code&gt;AccessDenied&lt;/code&gt;, the action needs the bucket ARN, as the multipart overview says. We haven’t run this test.&lt;/p&gt;

&lt;p&gt;A denied call prints HTTP 403, usually as &lt;code&gt;AccessDenied (HTTP 403)&lt;/code&gt;. For a missing Allow, AWS documents a message that follows the caller’s ARN with “is not authorized to perform: s3:GetObject because no identity-based policy allows the s3:GetObject action” (&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/troubleshoot-403-errors.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;). That is AWS’s documented pattern; we have no captured output to show.&lt;/p&gt;

&lt;p&gt;To clean up with the CLI, delete the access key, then the inline policy, then the user. AWS’s &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/iam/delete-user.html" rel="noopener noreferrer"&gt;delete-user reference&lt;/a&gt; says a programmatic delete fails unless you remove the attached items first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws iam delete-access-key --user-name &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;TEST_USER&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; --access-key-id &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;ACCESS_KEY_ID&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
aws iam delete-user-policy --user-name &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;TEST_USER&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; --policy-name web-client-one-bucket
aws iam delete-user --user-name &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;TEST_USER&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To clean up in the console (&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_remove.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On the user’s &lt;strong&gt;Security credentials&lt;/strong&gt; tab, in &lt;strong&gt;Access keys&lt;/strong&gt;, choose &lt;strong&gt;Actions&lt;/strong&gt;, then &lt;strong&gt;Deactivate&lt;/strong&gt;, and confirm. AWS says that if users have active access keys, “you must deactivate the access keys before deleting the users”.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Users&lt;/strong&gt;, select the user’s checkbox and choose &lt;strong&gt;Delete&lt;/strong&gt;. Type the user name and choose &lt;strong&gt;Delete&lt;/strong&gt;. The inline policy is deleted with the user.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then give the same policy to the user whose key the web client will hold.&lt;/p&gt;

&lt;h2&gt;
  
  
  R2, B2, Wasabi, MinIO and Spaces scope keys differently
&lt;/h2&gt;

&lt;p&gt;MinIO and Wasabi take AWS-style JSON policies, while R2, B2 and Spaces scope a key through settings you choose when you create it. The test program works against any of them through &lt;code&gt;ENDPOINT&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;How a key is scoped&lt;/th&gt;
&lt;th&gt;Closest to this policy&lt;/th&gt;
&lt;th&gt;Watch out for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://developers.cloudflare.com/r2/api/tokens/" rel="noopener noreferrer"&gt;Cloudflare R2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;API tokens with preset permission levels&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Object Read &amp;amp; Write&lt;/strong&gt;, which allows “read, write, and list objects in specific buckets”&lt;/td&gt;
&lt;td&gt;Admin Read &amp;amp; Write can also create, delete and configure buckets; only the Object levels can be scoped to buckets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.backblaze.com/docs/cloud-storage-application-keys" rel="noopener noreferrer"&gt;Backblaze B2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Application keys&lt;/td&gt;
&lt;td&gt;A key limited to one bucket, and optionally to a file-name prefix&lt;/td&gt;
&lt;td&gt;S3 ListBuckets needs the list-all-bucket-names setting, offered only on single-bucket keys; a prefix key lists only under a prefix at least as restrictive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://docs.wasabi.com/docs/how-do-i-set-up-wasabi-for-user-access-separation" rel="noopener noreferrer"&gt;Wasabi&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;IAM-style JSON policies&lt;/td&gt;
&lt;td&gt;Its single-bucket example grants &lt;code&gt;"s3:*"&lt;/code&gt;; trim it to this post’s actions&lt;/td&gt;
&lt;td&gt;Its console needs &lt;code&gt;ListAllMyBuckets&lt;/code&gt;; a client given the bucket name may not, so test it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://docs.min.io/enterprise/aistor-object-store/administration/iam/access/" rel="noopener noreferrer"&gt;MinIO&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Policies in the AWS IAM policy schema&lt;/td&gt;
&lt;td&gt;This post’s policy, created and attached with &lt;code&gt;mc&lt;/code&gt; (below)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;arn:aws:s3:::data*&lt;/code&gt; also matches the buckets &lt;code&gt;data_private&lt;/code&gt; and &lt;code&gt;data_internal&lt;/code&gt;, so name the bucket exactly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://docs.digitalocean.com/products/spaces/how-to/manage-access/" rel="noopener noreferrer"&gt;DigitalOcean Spaces&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Limited-access keys per bucket&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Read/Write/Delete&lt;/strong&gt; on the one bucket&lt;/td&gt;
&lt;td&gt;Limited-access keys are incompatible with &lt;code&gt;PutBucketPolicy&lt;/code&gt; bucket policies&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For the CORS side of a browser client on MinIO, see &lt;a href="https://opndrive.app/blog/fix-cors-errors-on-a-minio-bucket-community-vs-aistor-and-how-to-test" rel="noopener noreferrer"&gt;fix CORS errors on a MinIO bucket&lt;/a&gt;. MinIO’s &lt;a href="https://github.com/minio/minio/blob/master/docs/multi-user/README.md" rel="noopener noreferrer"&gt;multi-user guide&lt;/a&gt;, in a community repository archived and read-only since 2026-04-25, creates and attaches a policy like this, with &lt;code&gt;&amp;lt;ALIAS&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;USER&amp;gt;&lt;/code&gt; as placeholders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mc admin policy create &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;ALIAS&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; web-client-one-bucket policy.json
mc admin policy attach &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;ALIAS&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; web-client-one-bucket --user=&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Try Opndrive
&lt;/h2&gt;

&lt;p&gt;Opndrive gives any S3-compatible bucket a Drive-like web interface you host yourself.&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/Opndrive/opndrive" rel="noopener noreferrer"&gt;See it on GitHub&lt;/a&gt; or &lt;a href="https://docs.opndrive.app" rel="noopener noreferrer"&gt;read the docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First published on &lt;a href="https://opndrive.app/blog/the-minimum-iam-policy-for-an-s3-web-client-one-bucket-least-privilege" rel="noopener noreferrer"&gt;opndrive.app&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>infrastructure</category>
      <category>security</category>
    </item>
  </channel>
</rss>
