S3: Custom Upload Directory



  • Is it possible to set a custom upload directory directory so that the WP files aren't uploaded to the root of the bucket?

    Instead of:

    /2017
    /2018
    /2019

    Organize like this:

    /wp-content/uploads/2017
    /wp-content/uploads/2018
    /wp-content/uploads/2019



  • @iTim314

    Yes you can set a path prefix to whatever you want. In the Cloud Storage settings:

    Screenshot of Safari (7-20-19, 1-26-26 PM).png

    In your example, you'd set it to wp-content/uploads/@{date:Y/m}.



  • This is not working. It continues to upload to the bucket root using the default Wordpress format.

    alt text



  • Are you using the migrate to cloud feature and it's not working with that?



  • You would be correct. In fact I just tried to upload a new image and it followed my specified object prefix. It appears to only be the Migrate to Cloud process that's ignoring it.



  • Yeah in the 4 years this plugin has existed, there has been a lot of go around on how the migrate to cloud should work and the larger consensus is that it should retain the original directory structure which is why it ignores the path prefix.

    There's actually some pretty good reasons why:

    • If your custom prefix has a date in it, it will always return with today's date. For example, if your custom prefix is some/path/@{date:Y/m}, the prefix will always resolve to today's date. So if you have a media library that spans eight years, they will all get dumped into the same directory when you import to the cloud.
    • Media Cloud would have to move your local files around and update other existing metadata which may break posts.


  • @jong That's unfortunate. I understand the re-dating issue. I do wish though that you could set a prefix for the migration that excluded the date as such that it just did a simple copy of the existing file structure. Plus, it's already having to re-link all media files in the post, so it's not much different than replacing www.foo.bar/2017/01/... with s3.foo.bar/2017/01/...



  • @iTim314

    That I think can be done, but you'll need to give me a couple of days to implement it.



  • By all means, take your time. 🙂 I love what I see so far and this is the one thing keeping me from implementing the plugin.



  • @iTim314

    3.1.0 was just released which tackles this. You can read more about it here:

    https://talk.mediacloud.press/topic/40/3-1-0-release-notes



  • I'm amazed at the speed of which you implemented a one-off feature request. It does EXACTLY what I wanted it to do! Thank you very much.



  • I should note that the Regenerate Thumbnails process ignores the prefix and places the new thumbnails in the bucket root using the default WP @date function.


Log in to reply