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

Special characters in filename causes uploads to fail #133

Open
jet10000 opened this issue Apr 8, 2022 · 13 comments
Open

Special characters in filename causes uploads to fail #133

jet10000 opened this issue Apr 8, 2022 · 13 comments
Labels
accepted Accepted for further investigation and prioritisation bug Something isn't working

Comments

@jet10000
Copy link

jet10000 commented Apr 8, 2022

Bug report

When upload "望舌诊病.pdf"

Describe the bug

image

@jet10000 jet10000 added the bug Something isn't working label Apr 8, 2022
@thebengeu thebengeu transferred this issue from supabase/supabase Apr 8, 2022
@thebengeu
Copy link
Member

Thanks for the bug report @jet10000! We'll take a look.

@alaister alaister changed the title Storage upload file bug Special characters in filename causes uploads to fail Apr 8, 2022
@rahul3v
Copy link
Contributor

rahul3v commented Apr 12, 2022

@thebengeu @jet10000 @alaister
As per now for both objectName and bucketName , supabase only allow s3 safe characters as per AWS guideline here

 // only allow s3 safe characters and characters which require special handling for now
 // https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html

@alaister
Copy link
Member

S3 supports UTF-8 characters in filenames. However, at the moment, we are very strict with which filenames we allow.
I think this is a valid use case to add support for different languages in filenames.

One option is to update the isValidKey function https://github.com/supabase/storage-api/blob/9480891af024396c58045578d16c91778aae67d2/src/utils/index.ts#L76-L80 to allow everything aside from the characters outlined in https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html#object-key-guidelines-avoid-characters

@PiddePannkauga
Copy link

I would love support for å,ä,ö.

Love from Sweden

@fenos fenos added the accepted Accepted for further investigation and prioritisation label Sep 7, 2022
@alaister alaister removed their assignment Dec 28, 2022
@Xuanwo
Copy link

Xuanwo commented May 2, 2023

Hi, opendal meets a similiar problem in apache/opendal#2190 that we have a test case (which passed on most storage platforms from s3, gcs, azalob to hdfs) like the following:

let path = format!("{} !@#$%^&()_+-=;',.txt", uuid::Uuid::new_v4());

Does this case make sense to you? I'm willing to help fix this. I believe that all URL-unsafe characters should be percent-encoded, and the server-side should handle the job of decoding them.

@javierfern03
Copy link

I would love support for ´ I can't use words with accents in my images, which is very common in Spanish.

@turulix
Copy link

turulix commented Jan 29, 2024

Also ÖÄÜ in german

@orlein
Copy link

orlein commented Feb 1, 2024

I could understand that the isValidKey function looks like because it would be safe if the system accepts only the alphabet.
As I'm Korean, there is no good way to safely convert from the Korean characters(hangul) to alphabet. It would be same for the Japanese characters and Chinese characters too.
Are there any specific reasons for the function's regex? If the function accepts the encoded characters from encodeURIComponent function, it would be great.

@li4man0v
Copy link

MacOS generates screenshot names that don't match the pattern in isValidKey. For example, "Screenshot 2024-01-24 at 12.25.39 AM".

@jingsam
Copy link

jingsam commented Apr 20, 2024

Ops! This issue seems easy to fix but have last for 2 year's. Unbelievable!

@ThaddeusJiang
Copy link

hi everyone

My solution is base64 encoding when uploading file, demo: https://github.com/ThaddeusJiang/supabase-helpers/blob/main/backup_storage_buckets.ts#L71-L73

@gitnik
Copy link

gitnik commented May 20, 2024

This is a big pretty big oversight. At the very least it would be nice if this was documented somewhere

@stefan-girlich
Copy link

stefan-girlich commented Jun 6, 2024

You can upload files using any name (e.g. base64, thx @ThaddeusJiang ), store the original file name in a different table, and then use it when generating the public link:

const {
  data: { publicUrl },
} = supabase.storage
  .from('my_bucket')
  .getPublicUrl(internalFileName, { download: originalFileName })

Source (for URL access): https://supabase.com/docs/guides/storage/serving/downloads#downloading
The supabase-js docs unfortunately do not mention this yet: https://supabase.com/docs/reference/javascript/storage-from-getpublicurl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Accepted for further investigation and prioritisation bug Something isn't working
Projects
None yet
Development

No branches or pull requests