Graphcool / graphcool-framework

Apache License 2.0
1.77k stars 130 forks source link

Preserve extension when uploading files #59

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by sedubois Sunday Apr 23, 2017 at 10:39 GMT Originally opened as https://github.com/graphcool/prisma/issues/180


My first step to migrate has been to upload many files to Graphcool. However, I can't reference them from my old codebase, because the file extension isn't exposed in the URL, and a library in this old code only understands images with file extensions. This is a limitation which won't get fixed. I might have similar issues with other content like audio and videos.

Even if I only need this in the interim while migrating, it would be great if Graphcool could preserve file extensions, because this procedure will likely take weeks or months. At the moment it therefore appears that I'm blocked.

(This might be a particular example of a more generic need to expose (a subset of) the filename in the URL (or some other metadata such as a "title" or "description"). E.g Medium exposes URLs which are impossible to guess, but also legible.)

Thanks!

marktani commented 6 years ago

Comment by sedubois Thursday Jun 08, 2017 at 15:03 GMT


I thought that I got around this issue, but found several places in my legacy codebase which reference the file extension (this time, just found issue in iOS swift code). So I need to switch back my migration towards CloudFront which preserves the file extensions (and which also preserves signed URLs: #182).

marktani commented 6 years ago

Comment by sedubois Thursday Jun 15, 2017 at 07:01 GMT


OK, I got around this specific issue by adding ?hint=.mp4 to the URL 😄

marktani commented 6 years ago

Comment by kbrandwijk Thursday Jun 15, 2017 at 09:06 GMT


You could also create a small wrapper on webtask.io with the filename in the url I guess.

marktani commented 6 years ago

Comment by sedubois Friday Jun 16, 2017 at 23:17 GMT


Thanks @kbrandwijk for the suggestion. I found yet another problematic place (Android client this time which was really expecting an .mp4 extension in the path itself, no good in query params), and after going back and forth with other solutions I figured out I could just use a CloudFlare URL forwarding rule to redirect my.sub.domain.com/*.mp4?hint=other-string-which-was-also-expected onto https://files.graph.cool/$1... (where $1 matches the *.) Maybe I could have done something similar with webtask.io, but I like CloudFlare and was already using it.

In case it helps someone else 😄 Considering how much time it took me to figure this out (I'm no expert, which is why I'm interested in Graphcool in the first place), it would really help if Graphcool allowed enriching the URL with a custom string (incl. the ending) and I guess it wouldn't be that complicated.

marktani commented 6 years ago

Comment by kbrandwijk Sunday Jul 16, 2017 at 05:55 GMT


See https://github.com/graphcool-examples/functions/tree/master/file-proxy#extension-file-proxy