clineamb / gulp-s3-upload

A gulp task to upload/update assets to an S3 account.
62 stars 37 forks source link

Possible to set custom HTTP headers? #44

Closed Jos512 closed 7 years ago

Jos512 commented 7 years ago

Can we use gulp-s3-upload to set custom HTTP headers? I know of the Metadata argument, but with code like this:

gulp.task('uploadS3', function() {
    return gulp.src('deploy/assets/style.css')
        .pipe(s3({
            Bucket: 'www.example.net',
            ACL: 'public-read',
            uploadNewFilesOnly: false,
            Metadata: {
                "Example-Header": "Example"
            },
        }, {
            maxRetries: 5,
        }));
});

The HTTP header that's set is:

x-amz-meta-example-header:"Example"

I'm not sure whether the plugin or aws-sdk-js adds the 'x-amz-meta' prefix and performs lowercasing, but I do know from these issues (here and here) that it's possible to upload objects with custom headers.

Am I overlooking a feature of this plugin, or isn't this possible?

Edit: I just learned now that AWS' PUT object operation can specify a couple of HTTP headers. Because the HTTP header that I want to add is not in that allowed list, it doesn't seem to be possible to set the custom header I'm looking for.

(This issue can be closed from my standpoint.)

clineamb commented 7 years ago

@Jos512 : Yeah, x-amz-meta is added by AWS upon using the API with the way this plugin is setup right now. In terms of a feature, I can take a look, but as you figured out, this plugin is still limited to what AWS allows. But thanks for the heads-up on these similar issues. (:

galangel commented 7 years ago

I also wish it was without the x-amz-meta =) I love how you give the option to use different metadata by function return, im testing my page using google insights and its not recognizing the x-amz-meta-cache-control