danmasta / ghost-gcs-adapter

Ghost GCS Storage Adapter
MIT License
8 stars 2 forks source link

Spaces in filenames #7

Closed WitchFreya closed 3 years ago

WitchFreya commented 3 years ago

Great work on the adapter! It's the only thing we've run into for GCS with Ghost at the moment that properly works with folders. The only issue we're having at the moment is that it doesn't currently support spaces in file names, is that something that would be possible to add?

danmasta commented 3 years ago

@WitchFreya Thank you, glad you find it useful! Sure I can take a look at that. Are you seeing any errors? Can you give me an example of what you are seeing happen with the spaces in file names so I know where to look?

WitchFreya commented 3 years ago

I haven't seen anything in terms of error message except for when retrieving them image. It looks like it might be an issue with the URI encoding of spaces and other special characters. Example:

  1. I upload an image with the name "sample image.png"
  2. It uploads properly to Google Cloud, but the name of the file is wrong there. It appears in Google Cloud as "sample%20image.png". As a result, the public URL is encoded a second time, making it "sample%2520image.png".

My best guess is that you're encoding the URI before upload and then Google Cloud is encoding it again for the public URL. I believe this is something that's a result of the storage adapter.

Does this help?

danmasta commented 3 years ago

I was able to replicate the issue, just pushed a fix for this. It was originally using the url api to generate the relative file paths, but that api does automatically url encode the path strings which was the issue. I updated it to support spaces, but one thing to note is that the default ghost storage adapter does not support spaces. I left some notes in #8 if you're curious.

Thanks for the feedback!

danmasta commented 1 year ago

Hi @WitchFreya I know this is an old issue, and maybe you aren't even using this package anymore, but I just wanted to let you know that based on your feedback I updated the plugin to sanitize file name input based on the gcs file name requirements and recommendations. I also added support for ascii folding, based on the lucene database implementation, which is a more robust way to sanitize input to the basic ascii characters and should improve stability for file name support dramatically.

Thank you for the feedback, and yes it did help. I appreciate it!