scar
scar copied to clipboard
Set ContentType for S3 uploads
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?
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
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.
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?
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.