scar icon indicating copy to clipboard operation
scar copied to clipboard

Set ContentType for S3 uploads

Open tomberek opened this issue 5 years ago • 4 comments

Allow a method by which workers can set the contentType of the uploads. Not sure about the design. Perhaps a special .scar.yaml or other file name specified in the function specification that is read and used to populate ContentType in a YAML mapping?

tomberek avatar Jul 31 '19 13:07 tomberek

Hi, thanks for using SCAR!, I have a some questions about your issue. From the issue, I understand that you want to be able to define the content-type metadata of the files stored in S3.

What I don't understand is from where do you want to do it, I mean, are you uploading the files using SCAR? , like scar put -b bucket/folder -p my-file, or do you want to define the content-type of the files uploaded by the lambda function at the end of the execution?

For the first option we could add an extra parameter in the CLI with the content type, for the second option, maybe we can analyze the ending of the file and automatically set the content type for a predefined set of files.

Did I understand you correctly? What option would you need?

Regards

alpegon avatar Sep 05 '19 10:09 alpegon

I was asking about the second option. I found where this is done, but currently it sets a blank content-type. I’ve tested hard coding it for my needs, but I am not sure what the right design is to expose it to users as a setting/configuration.

tomberek avatar Sep 05 '19 11:09 tomberek

I think we can include in the function payload a json file with some regex : type format like {".*\.png" : "image/png", ".*\.txt" : "text/plain"} and then check if the json file exist when the generated output files are going to be uploaded. If the json file exist, for each file we would look if it matches some pattern and set the type accordingly. If the json file doesn't exist or the file to upload doesn't match any pattern we leave the default type as we are doing now.

Do you think this approach could help you?

alpegon avatar Sep 06 '19 10:09 alpegon

Ok, I can do that, no problem. In return I would like to know (if you don't mind) what is your use case. This project is a part of my PhD and I'm interested in applications created by the community. You can send me an email to alpegon3 at upv.es if you don't like to write it here. Thank you very much.

alpegon avatar Sep 18 '19 10:09 alpegon