mootoday / ghost-v3-google-cloud-storage

A Google Cloud Storage adapter for Ghost v3 (www.ghost.org).
13 stars 7 forks source link

Request: randomise filenames #2

Open johngoggs opened 4 years ago

johngoggs commented 4 years ago

Hi Mike,

Coming from Wordpress earlier this year, I had a GCS addon that would randomise filenames to ensure filenames are not the same. Renaming filenames exist, but it will amend a 1 on the end of the filename, and I don't want to see the original filenames in each request.

I understand that I could randomise the filenames myself, but I would end up losing track of each file.

FYI - great addon :)

Thanks.

mikenikles commented 4 years ago

Hi,

Could you share the link to that Wordpress GCS add-on? I'd like to understand what the benefits are of randomizing file names. What is your motivation to randomize file names? You said you don't want to see the original file names in each request - why is that?

From my experience with Ghost so far, each file upload results in a unique (although not random) file name which is likely to make sure old versions of the same file are not cached.

johngoggs commented 4 years ago

Hi Mike,

Sorry for the long delay. I took a few weeks off work, and I forgot about this request.

Wordpress Plugin: https://en-gb.wordpress.org/plugins/wp-stateless/

For me, the benefit of randomising filenames is to keep the filename pattern consistent and tidy. For example, if you upload a file called screenshot.png, the next time you upload the same file or a file with the same file name during the same month, it will add a number onto the end of the filename, i.e. screenshot-1.png.

During a post, I may upload the same file, or an overwrite of the same filename multiple times, this means I end up with a lot of images that I need to clean up manually.

This request is less so about unique filenames, as they are already unique. It's more about my workflow and keeping filenames consistent during each upload.

mikenikles commented 4 years ago

A few weeks off sounds good and not replying here is the right thing to do when you're off work ;-).

I fully agree with you and look at that as two separate issues:

1) File names and their naming conventions I'd prefer to keep this GCS storage adapter as basic as possible. Having said that, my preference would be for authors to make sure file names follow a good naming convention. For example, you could prefix files you upload with the blog post's slug to keep them nicely tied to individual posts.

2) Delete unused files from storage From what I can tell, Ghost doesn't support this at the moment. Here's a question from last May. If you really wanted to automate this, here's a thought: