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

Set content type based on file extension #155

Closed
nottix opened this issue Jan 31, 2016 · 17 comments
Closed

Set content type based on file extension #155

nottix opened this issue Jan 31, 2016 · 17 comments

Comments

@nottix
Copy link

nottix commented Jan 31, 2016

Hi,

i'm trying to copy png and jpeg on a bucket, but it set always the content-type to octetstream instead of image/png or image/jpeg.

Thank you.

@suhas22
Copy link

suhas22 commented Feb 5, 2016

Hi There,
We are facing somewhat a similar issue.
As per the code, if content type is not set, then gcsfuse defaults it to octetstream, but in our case for some of the files it is setting to "folder". due to which the streaming jobs from spark fail complaining that the file format is not correct.
We have tested it on both versions 0.12 & 1.15.1

Any help is greatly appreciated.

@jacobsa
Copy link
Contributor

jacobsa commented Feb 8, 2016

gcsfuse doesn't manage GCS metadata for the user (and in general this is impossible or requires error-prone sniffing). If you care about setting these properties, you'll need to set them yourself using the GCS storage browser or the GCS API.

@jacobsa jacobsa closed this as completed Feb 8, 2016
@nottix
Copy link
Author

nottix commented Feb 15, 2016

Hi @jacobsa

searching the web i found that similar tool (like s3fs-fuse) support the mapping of the content-type by means of the mapping file.
gcsfuse currently appears to be the only available tool to use "google cloud storage" with fuse and it lacks of this feature.

Thank you.

@jacobsa
Copy link
Contributor

jacobsa commented Feb 15, 2016

As I said above, you can do this with content sniffing but it's error prone and I think it's not a good decision engineering-wise. Could you say a bit more about why you need this? Again, you can easily set this value using the GCS API.

@nottix
Copy link
Author

nottix commented Feb 15, 2016

But we can skip content sniffing observing only the file extension, i know that it's error prone but i don't see other ways.

I'm using gcsfuse to map uploads directory of Wordpress to share directory between multiple instances. I have to upload images, directories, text, doc etc.

@CeccoCQ
Copy link

CeccoCQ commented Feb 16, 2016

+1

@nottix
Copy link
Author

nottix commented Feb 16, 2016

so, @jacobsa do you have any plan to add this feature?

Thank you.

@jacobsa
Copy link
Contributor

jacobsa commented Feb 17, 2016

Can you explain why it's important that you have a content type set in GCS? If you're using GCS as a file system it's meaningless, so I assume it's interoperability with some other use. Can you also explain why using the GCS API to set it doesn't work well for you?

@nottix
Copy link
Author

nottix commented Feb 17, 2016

I'm using gcsfuse to sharing a directory between multiple instance of our Wordpress portal, then it's Wordpress that put files on gcs using gcsfuse and i can't edit content-type via API.

@jacobsa
Copy link
Contributor

jacobsa commented Feb 17, 2016

Thanks, but how about the first question: why is it important that content type be set in the first place?

@nottix
Copy link
Author

nottix commented Feb 17, 2016

Because the files will be missinterpreted by web browers. A link URL to an image with content-type octetstream can by downloaded and did not view by a browser.

@jacobsa
Copy link
Contributor

jacobsa commented Feb 17, 2016

Okay. I see how pragmatically it's a good idea to set a default based on extension. If gcsfuse gets it wrong the user is no worse off than now -- they must go and use the API to fix it. Thanks for your patience.

@jacobsa jacobsa reopened this Feb 17, 2016
@jacobsa jacobsa changed the title Wrong Content-Type Set content type based on file extension Feb 17, 2016
@jacobsa
Copy link
Contributor

jacobsa commented Feb 17, 2016

Implementation note: will want to use mime.TypeByExtension.

@nottix
Copy link
Author

nottix commented Feb 17, 2016

thank you @jacobsa

How long do you think it takes to implement it?

@jacobsa
Copy link
Contributor

jacobsa commented Feb 18, 2016

I'll try to get to it soon.

jacobsa added a commit that referenced this issue Feb 18, 2016
jacobsa added a commit that referenced this issue Feb 18, 2016
jacobsa added a commit that referenced this issue Feb 19, 2016
jacobsa added a commit that referenced this issue Feb 19, 2016
jacobsa added a commit that referenced this issue Feb 19, 2016
jacobsa added a commit that referenced this issue Feb 19, 2016
@jacobsa
Copy link
Contributor

jacobsa commented Feb 19, 2016

Hi all, please try gcsfuse 0.17.0 and let me know how it works for you.

@nottix
Copy link
Author

nottix commented Feb 20, 2016

It works perfectly, i'll continue to test it. Thank you ;-)

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

No branches or pull requests

4 participants