Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature suggestion: Allow user to specify metadata for uploaded files #24

Closed
linusmarco opened this issue Feb 20, 2018 · 5 comments
Closed
Assignees

Comments

@linusmarco
Copy link
Contributor

S3 bucket hosting allows you to set HTTP headers for responses to incoming requests via "Metadata" for each object in the bucket. It would be great to be able to specify these through the options in serverless.yml.

A specific use case for this would be for setting Cache-Control headers, which are particularly important for making sure that browsers don't cache files on your site that may change frequently.

I'm imagining this as an optional parameter in serverless.yml that could specify metadata for any specific file or folder as well as for the every object in the bucket. File-specific metadata would override folder-specific metadata, which would in turn override ALL_OBJECTS metadata.

custom:
  client:
    ...
    objectMetadata:
        - specific-file-that-shouldnt-be-cached:
            - mdata-name: Cache-Control
              mdata-value: no-cache
            - mdata-name: Content-Language
              mdata-value: es-ES
        - folder-with-other-caching-requirements:
            - mdata-name: Cache-Control
              mdata-value: max-age=10000
        - ALL_OBJECTS
            - mdata-name: Content-Language
              mdata-value: en-US

I'm happy to work on a PR for this

@fernando-mc
Copy link
Owner

@linusmarco makes sense to me. I've run into this issue before a ton myself and had to deal with it manually. I'd love to be able to specify that in the config once and avoid doing it manually.

Go for it. I will admit I'm slower merging things these days because I need automated tests still and there are quite a few use-cases to test for now.

@linusmarco
Copy link
Contributor Author

Sounds good! I'm also happy to help you in writing up tests for new (or existing) functionality. Let me know if there's any specific place you'd want me to start.

@fernando-mc
Copy link
Owner

@linusmarco Tests for literally anything would be great. I'm honestly not sure where to start as I've never written tests for anything like this before.

@linusmarco
Copy link
Contributor Author

Sounds good! I'll submit tests to go along with this PR and then move on to testing other parts of the library from there.

@fernando-mc
Copy link
Owner

@linusmarco V2 does this 😀
Thanks for implementing it! Should be in V2 so I'm closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants