Browse Source

s3: Add Multipart-specific CORS documentation.

Renée Kooi 7 years ago
parent
commit
df2e6afca0
2 changed files with 22 additions and 0 deletions
  1. 4 0
      src/plugins/AwsS3/MultipartUploader.js
  2. 18 0
      website/src/docs/aws-s3-multipart.md

+ 4 - 0
src/plugins/AwsS3/MultipartUploader.js

@@ -201,6 +201,10 @@ class MultipartUploader {
 
       // NOTE This must be allowed by CORS.
       const etag = ev.target.getResponseHeader('ETag')
+      if (etag === null) {
+        this._onError(new Error('AwsS3/Multipart: Could not read the ETag header. This likely means CORS is not configured correctly on the S3 Bucket. Seee https://uppy.io/docs/aws-s3-multipart#S3-Bucket-Configuration for instructions.'))
+        return
+      }
 
       this._onPartComplete(index, etag)
     })

+ 18 - 0
website/src/docs/aws-s3-multipart.md

@@ -99,3 +99,21 @@ Return a Promise for an object with properties:
  - `location` - **(Optional)** A publically accessible URL to the object in the S3 bucket.
 
 The default implementation calls out to Uppy Server's S3 signing endpoints.
+
+## S3 Bucket Configuration
+
+S3 buckets do not allow public uploads by default.  In order to allow Uppy to upload to a bucket directly, its CORS permissions need to be configured.
+
+This process is described in the [AwsS3 documentation](/docs/aws-s3/#S3-Bucket-configuration).
+
+On top of the configuration mentioned there, the `ETag` header must also be whitelisted:
+
+```xml
+<CORSRule>
+  <AllowedMethod>PUT</AllowedMethod>
+  <!-- ... all your existingCORS config goes here ... -->
+
+  <!-- The magic: -->
+  <ExposeHeader>ETag</ExposeHeader>
+</CORSRule>
+```