Loading pre-existing S3 bucket files into Directus File Library

Hi. Does anyone know if there’s a way, when using S3 as the storage location, to get the File Library to load contents of the S3 Bucket that are already there or have been added outside of Directus?

Any help/advise greatly appreciated!

Thanks

1 Answer

1

Just so I understand clearly, you’ve got a previous S3 bucket that you’ve connected to Directus. It had files in it already, and you want those files to show up inside the Directus file library? Is that correct?

If that’s the case, then you’ll have to add those files to the database connected to Directus.

If you want them to show up, they have to live inside the directus_files collection in order to display or get served by the Directus API.

That comes with a few challenges because we use the UUID of the file as the file name in the S3 bucket.

So my recommendation would be to re-upload those files to the Directus instance.

If it’s a lot of files you could probably script it fairly easily.

Thanks. Yes, that's correct. The issue we face is that we are trying to migrate a client from a previous solution and there are well over 250,000 assets in their S3 Bucket - which they'd like to be able to accessible via the File Library (so they can assign meta data, use within content etc.). I was hoping there might be some way that Directus could introspect the storage location, like it does with databases, but if not possible we'll explore scripting something or building a custom interface. thanks.

There's no automated introspection as of v11.8. To Bryant's point the easiest path is usually to use the API to move the files back in, but if you want to prevent that with such a large number of assets you could get there quicker by inserting the metadata records required directly in the database. As long as you make sure the filename_disk field matches up with the actual location in the bucket things should generally work as expected. That being said, YMMV!