How Do I Change File Upload Directory From Droplet File System To Volume Block Storage


How Do I Change File Upload Directory From Droplet File System To Volume Block Storage?

I have a Droplet running Ubuntu 18.04 with Apache. I have a project wherein I need to upload lots of videos and hence I added a Volume of 100GB to my Droplet.

Default project video upload path is /var/www/html/public/uploads/videos and i want to change this location to /mnt/volume_blr1_01/uploads/videos

I have tried Symlink with the below command but symlink doesn’t seems to change location of video upload sudo ln -s /mnt/volume_blr1_01/uploads/videos /var/www/html/public/uploads/videos

I also tried adding alias in conf file and failed.

Also, the videos that i upload in block storage /mnt/volume_blr1_01/uploads/videos needs to be secured where only my project can access it and no direct requests

Can anyone please help how can I achieve this or what would I have to do?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey friend,

For the purpose of my answer, I’m going to assume the block storage device is /dev/sda. In that case I would do this:

# Unmount the current mount
umount /dev/sda

# Move the existing content aside for a moment
mv /var/www/html/public/uploads/videos /var/www/html/public/uploads/videos2

# Make a new, empty directory where the content needs to be
mkdir /var/www/html/public/uploads/videos

# Mount the drive to that new, empty folder
mount /dev/sda /var/www/html/public/uploads/videos

# Move the files from that temporary directory back into the right place
# which is now mounted as the directory in question
mv /var/www/html/public/uploads/videos2/* /var/www/html/public/uploads/videos

Then edit /etc/fstab to indicate the new mount location being /var/www/html/public/uploads/videos instead of the existing area in /mnt.