How to migrate images stored into S3 after changing the storage directory with the arc library

Hi everyone,

I’m using the arc / arc_ecto library to store medias on S3.

Recently I had to change the storing directory.
So I changed the function “storage_dir” to suit my new path to S3 like so:

def storage_dir(_version, {_file, %Media{} = scope}) do

And now that is done, all newly created medias are stored in the new directory and I can retrieve them correctly but it is impossible to retrieve medias stored in the old directory. The arc library generate an url that use the new storage directory and I can’t retrieve medias from the old one.

Does anyone know what can I do to migrate my medias from the old directory to the new one?
Is it possible to do it using Arc ecto or should I use another library related to S3?

Many thanks for your help.

I assume you are talking about files in the same bucket?

I think you can use the cli sync command


Note that folders are not actually a thing in s3 buckets though, they are basically just file names, so I am not 100% sure the sync command would work.

1 Like

Yes, files are in the same bucket.

Thanks for the answer, I’ll give it a try but I’m not sure this will solve my problem because the new path need to know my “”. I can’t do this in one line, my new path is not generic, it depends on the id (store in database) of each media