humanmade / S3-Uploads

The WordPress Plugin to Store Uploads on Amazon S3
1.94k stars 391 forks source link

Removing files from server that are synced #360

Closed momark closed 4 years ago

momark commented 4 years ago

We already had a couple of thousand files on our server when we installed the S3-uploads plugin. We uploaded all the files to our S3 bucket and activated the plugin. Most of the image URLs have been changed to our bucket URL, but we have the following issues:

  1. We see some images still served from our server (e.g. logo and favicon). How can we make sure all images load from S3?
  2. Is there a way to safely remove all the media images from our server so that we save some space? We don't want to keep the images on our server when all of it has been uploaded to S3.
  3. The --sync option doesn't work in the command line. It doesn't recognize the parameter.

Thanks in advance.

pixelbrad commented 4 years ago
  1. Not too sure on this one, but you might want to check if the files coming from the web-server are hard-coded into templates.
  2. I think it is implied that media objects ultimately 'move' from the web-server to S3 (i.e. once they're up on S3, they're removed from web server). I also think there is an issue in the way the upload-directory command functions. I've been testing this plugin on a test site with WP debugging + debug logging enabled. The following is logged for every media object uploaded to S3:
    [04-Dec-2019 03:25:53 UTC] PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /path/to/my/app/wp-content/plugins/S3-Uploads/vendor/aws/aws-sdk-php/src/S3/Transfer.php on line 426
    The media objects ultimately make it to S3 and I can see they're being served from S3 in the media library. But perhaps this warning ties in to why media objects are not being removed from the server.
  3. Can't help you there.

My guess is, this codebase (or at least parts of it) need an overhaul.

dsgolfside commented 4 years ago

im specifically wanting to use this plugin to upload the entire "uploads" folder ...and definitely need the option to delete the files from the local web server after they are uploaded to s3 ....delicious brains offload s3 does this .....will this plugin delete the files that made it up to s3?

noplanman commented 4 years ago

It doesn't do the deleting automatically, but you can delete the uploads folder after copying everything to your S3 destination. I'd suggest to just rename it initially, to make sure everything works well.

Remember to use the --verbose flag for the upload-directory command to see any errors.)

joehoyle commented 4 years ago

@momark you'll need to do a DB replacement for the old urls pointing to your local server, to instead point them to the S3 URL (presuming you changes thee urls, and are not mapping the old uploads url to S3 directory).