V8-archive: File Naming Options

Created on 22 Aug 2018  Â·  21Comments  Â·  Source: directus/v8-archive

Our options should be:

uuid (replaces the old hash)
original (appends *-n as needed)
id (padded with 0)

Do ya'll agree with using uuid as a file naming default? We _could_ use original, but I think id is the default right now... and we definitely shouldn't use that one.

bug question documentation

Most helpful comment

Hey all, was this option removed at some point? In Directus 6 we had the option under "Global Settings" to set the ID used when uploading files. If I need to open a feature request, I can do that too.

image

EDIT: Found it, nevermind. If I had read through your comments, I would've seen it's now a database-exclusive setting. Added the row to directus_settings and works a charm.

All 21 comments

@benhaynes should the id appends the number suffix (*-n) to avoid duplication in case of storage not being empty. Replace the file or appends the suffix?

For id I would say it should overwrite it if it already exists.

I belive original should be the default one.

In fact, original it is the default option. When there's not option set, the original is the one used by default.

Original works for me, but on demo and my install it's using I'd... so I assumed that's the default

@rijkvanzanten can we update those demos?

Are you sure it's the default? The demo SQL doesn't have that option set at all in directus_settings or elsewhere so it uses the API defaults (? 🤔

@rijkvanzanten I am, _although you make me doubt a bit_, the only way to use id or uuid it is to set the setting file_naming to either id or uuid otherwise it will use the "original" filename, and appends number if there's a existing file.

@rijkvanzanten I tested on the demo server, and it actually works as expected, original is the default unless id or uuid is defined as file_naming

Yeah, it looks like it's in the database as file_id.

@rijkvanzanten can we re-install the demos so the schema/seeder is up to date?

You want to make the demo up to date based on the values in the seeder, or the other way around?

I guess it will be a little bit of each. We need to update the seeder with the defaults we set up in the demo... but we also need to look at the current seeder API defaults and make sure those are honored in the demo.

So Users/Files needs to be updated to show as Cards, but File naming should update to original (not file_id).

Hey all, was this option removed at some point? In Directus 6 we had the option under "Global Settings" to set the ID used when uploading files. If I need to open a feature request, I can do that too.

image

EDIT: Found it, nevermind. If I had read through your comments, I would've seen it's now a database-exclusive setting. Added the row to directus_settings and works a charm.

We currently only have file uploads saving as "the original" file name, but this used to be an option that could be changed in the Settings (I no longer see it). Users should be able to choose between different ways to save files:

  • uuid or hash (default) — This is a unique hash that ensures file names can not be guessed or incremented.
  • original — This is filenames are saved now. It sanitizes the original file name and adds -n (an incremented int)
  • pk — we don't need to include this, but it would be another option that would use the primary key of directus_files as the file name.

Another option that may be cleaner is to convert directus_files to use a UUID PK... then we only have two options: UUID and Original. Thoughts?

Also, this should be:

  • In the docs so people know how to use it
  • In directus_settings by default so the value can be seen
  • In Global Settings (app) so that users can change it

We are currently using this feature in v7 by manually adding a row to directus_settings with the setting. Just FYI.

Adding a row to directus_fields for this field will make it show up in the settings pane as well

Cool. So we need to:

  • Update the migrations, installer, and default schema to include this by default
  • Update the Docs to describe the options
  • Change the default to uuid
  • Optional: Update the collection's default PK to UUID

I was hoping that this would give us a clear default for naming... but as of now it's exactly 50/50!

https://twitter.com/directus/status/1139618994879696897

UUID seems like a "safer" default, but we need to still support "Original" as a Global Setting. BUT, let's wait the last 4 days of the poll and see what we get!

UUID seems like a "safer" default

I would agree, also thinking about server admins, many people will just install and get started, it might be best for Directus to obscure by default.
The toggle option is also a great idea to allow admins to keep the original names if wanted. We could also store the original filename as the 'Title' of the file in the database.

We already store the original file name as in directus_files.name... so we could always add a helper endpoint later that downloads the file with the original name.

Fixed in #1059

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwkellyiii picture jwkellyiii  Â·  3Comments

metalmarco picture metalmarco  Â·  3Comments

24js picture 24js  Â·  3Comments

ondronix picture ondronix  Â·  3Comments

cdwmhcc picture cdwmhcc  Â·  3Comments