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

How to keep or specify ContentType of object to upload? #632

Open
neko-kawaii-nyan opened this issue Nov 27, 2023 · 6 comments
Open

How to keep or specify ContentType of object to upload? #632

neko-kawaii-nyan opened this issue Nov 27, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@neko-kawaii-nyan
Copy link

Mountpoint for Amazon S3 version

mount-s3 1.2.0

AWS Region

ap-northeast-1

Describe the running environment

Running in EC2 on Amazon Linux 2 using instance profile credentials against an S3 Bucket in the another account.

What happened?

I use S3 as a CloudFront backend for website hosting purposes.
Therefore, the html file placed in S3 must be displayed as a web page when accessed by a browser, but if placed via mount-s3, the ContentType will be binary/octet-stream, so the html file will be downloaded.

Is there any way to modify the ContentType of the object being uploaded to text/html?

[ec2-user@ip-10-0-54-13 ~]$ mount-s3 --version
mount-s3 1.2.0
[ec2-user@ip-10-0-54-13 ~]$ sudo mount-s3 mybucket /s3 --uid 900 --gid 900 --allow-other --log-directory /var/log/mounts3 --debug
[ec2-user@ip-10-0-54-13 ~]$ file --mime-type index.html
index.html: text/html
[ec2-user@ip-10-0-54-13 ~]$ sudo cp index.html /s3/b.html
[ec2-user@ip-10-0-54-13 ~]$ aws s3api head-object --bucket mybucket --key b.html --query ContentType
"binary/octet-stream"

This is probably the same behavior as #471 .

Relevant log output

No response

@neko-kawaii-nyan neko-kawaii-nyan added the bug Something isn't working label Nov 27, 2023
@ahmarsuhail
Copy link
Contributor

thanks for opening an issue @neko-kawaii-nyan. This is not something Mountpoint supports currently, we will be investigating if this is something we can support in the future. We are updating this to be a feature request.

@ahmarsuhail ahmarsuhail added enhancement New feature or request and removed bug Something isn't working labels Nov 27, 2023
@neko-kawaii-nyan
Copy link
Author

Thank you for your reply.
Is there any additional information I should provide here for the feature request?

@sam9191
Copy link

sam9191 commented Feb 17, 2024

I have the same problem. .css file won't work on a web page because its content-type is binary/octet-stream. If mountpoint-s3 can automatically set the correct content-type when it uploads a file to the S3 bucket, would be great.

@gerard67
Copy link

Hello,

just adding to the case as I get this same annoying "issue"...
A configuration option in mount-s3 to apply Mailcap mime-types when uploading to S3 would be very usefull

@sagebind
Copy link

sagebind commented Feb 29, 2024

Perhaps extended attributes could somehow be leveraged to allow specifying content type (and perhaps other object metadata as well)? FUSE does support xattrs so it may be possible.

When uploading, the user would probably have to call fsetxattr on a new filesystem node after the file is created and opened for writing, and before writing any data, so that the attributes are all accessible to Mountpoint before it makes the first call to upload the object so it can include the desired headers.

It would be neat if the user.mime_type extended attribute defined by XDG were to be mapped automatically to object content type. If you were to use this for writes and exposed this extended attribute when reading as well, then file copies that preserve extended attributes would also preserve the S3 object content type.

For extra credit, other object metadata you could do an automatic header translation into an extended attribute namespace. For example, x-amz-meta-mykey could be exposed through Mountpoint as user.s3.x_amz_meta_mykey.

@infrahead
Copy link

Interesting ideas @sagebind but I wonder if that approach would add too much friction for different programming environments and runtimes vs normal file APIs and automatic detection. Maybe for advanced use cases.

IIRC, the AWS CLI does automatic mime-type detection (based on file extension?) and that would seem to me to be best starting place for Mountpoint as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants