How to upload large media to your WordPress site
How to upload large media to your WordPress site
Note This approach is very specific to a particular set of tools, but could be generalised to most setups
Context
- a website running Wordpress
- a large media file (or zip file containing media files) that is too large to directly upload
- (ideally) a tool such as WP Offload Media already installed and configured to offload media to an S3 bucket
You also need:
- a web-accessible location for the file (in my example, Microsoft OneDrive )
- shell access to your web server
- the WP CLI installed
Instructions
-
place your media file(s) in your web accessible service (in my example, Microsoft OneDrive for Business)
-
Generate a sharing link that is accessible to anyone with the link, copy and paste it into a text editor. In the case of OneDrive for Business, add
&download=1
to the end of the link.In the rest of this note, this full URL is referred to as
DOWNLOAD_URL
-
SSH into your web server as the correct user for your Wordpress site
-
create a temporary directory, for example
mkdir ~/mediatmp
-
cd ~/mediatmp
-
wget -c -O DESIREDFILENAME "DOWNLOAD_URL"
note the importance of putting the URL in double-quotes - this is so any special characters are not misinterpreted by your shell
wait for the download to complete
-
change directory to the root of your WordPress site, for example
cd ~/public_html
-
wp media import ~/mediatmp/DESIREDFILENAME
-
log into the backend of the site and go to to the media library, check the item is there and edit any settings
-
delete the temporary file(s) in
~/mediatmp