uppy icon indicating copy to clipboard operation
uppy copied to clipboard

@uppy/aws-s3: missing eTag prevents file upload completion when using GCS

Open pxue opened this issue 1 year ago • 4 comments

Initial checklist

  • [X] I understand this is a bug report and questions should be posted in the Community Forum
  • [X] I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

  1. set up AwsS3 but use GCS as drop-in replacement
  2. upload from local file

Expected behavior

Upload expects to complete successfully AND event completes

Actual behavior

Upload completes fine but onComplete is not called because missing etag shortcircuits the function

From GCS: https://cloud.google.com/storage/docs/metadata

Etag is not expected to return unless using XML API. While I can copy/paste the provider, this should work with GCS as well.

pxue avatar Jan 10 '25 07:01 pxue

The intermediate fix is to just clone the entire AwsS3 provider and implement it myself

instead of parsing eTag / location from the header, it's parsed from the response body

  static parseXMLResponse(xml: string | null) {
    if (!xml) {
      return {};
    }
    const parser = new DOMParser();
    const doc = parser.parseFromString(xml, "application/xml");
    const etag = doc.querySelector("PostResponse ETag")?.textContent;
    const location = doc.querySelector("PostResponse Location")?.textContent;
    return { etag, location };
  }

pxue avatar Jan 10 '25 14:01 pxue

I'm experiencing the same missing ETag error in @uppy/aws-s3: 4.2.3 when uploading to Backblaze B2 through the S3 compatible API even with the CORS settings on the bucket exposing ETag headers

ericvanular avatar Feb 12 '25 20:02 ericvanular

Have you seen https://github.com/transloadit/uppy/issues/5687#issuecomment-2920352792 regarding case sensitivity with CORS policy headers?

GFoley83 avatar Oct 02 '25 03:10 GFoley83

As i am facing the same issue with GCS, the Etag hack seems not working mentioned in comment. Because Etag is not a valid value i think. bellow i am getting from the gcs response, keep in mind this is in response there is no Etag header for the request

<PostResponse> <Location>location-url</Location> <Bucket>bucketname</Bucket> <Key>key-value</Key> <ETag>"Tag value"</ETag> </PostResponse>

subha1206 avatar Nov 05 '25 05:11 subha1206