Adding Files to the CT Content Portal Directly from a USB Drive

Although you can upload files to content.ct-networks.com over the web, if the records are in the office it my be quicker to add them directly to the file system of the server.

Plug your USB drive into the content server using one of the USB ports.  Bear in mind that not all ports are USB 3.0

SSH into the content server and elevate to root privileges.
Find the drive ID of the drive you inserted by typing blkid.  The results will be shown as /dev/sd??.  You can identify your drive using the LABEL= element which will match the name of your USB stick.  In the example below, our drive is /dev/sdd2 as the drive was called ‘Untitled’.  We will use /dev/sdd2 for the rest of this document but you should change this for the drive you want use.

You can now mount that drive so you can access the files on it. 
mount /dev/sdd2 /media/usbtransfer

Check you can see the files on your drive.
ls /media/usbtransfer

Now that the operating system has access to files we need to copy them to the correct folder.  NextCloud arranges files into folders by owner.  The owner is just the first person to upload the files, the can be shared from that location after.  Equally if a client already has a folder that has their appropriate shares is place we can copy the content there.

Check the available folders to confirm where the content should be copied. 
ls /media/datastorage

The command for the copy should follow the format: cp /media/usbtransfer/the-rest-of-the-file-or-folder-path /media/datastorage/file-owner/the-rest-of-the-file-path

In this example we to copy a file called Example.iso into the administrators folder, and placed into an existing folder structure so it automatically appears for people with that share. 
cp /media/usbtransfer/Example.iso /media/datastorage/administrator/files/Client\ Storage/Demo\ Client/Demo\ Client\ Videos/

Rough copy speeds are 6 minutes per GB using USB 2.0 drive and port.

The ownership of the files we just uploaded, as far as the OS is concerned, is incorrect and cannot be accessed by the web user, meaning NextCloud cannot access it.  we need to change the owner away from root (which we are logged in as) to www-data, which is the user NextCloud uses.  This example will change one file, add -R at the end to apply this recursively through folders. 
chown www-data:www-data /media/datastorage/administrator/files/Client\ Storage/Demo\ Client/Demo\ Client\ Videos/Example.iso

The file is in place but because NextCloud didn’t put it there, the database is unaware of its existence so it won’t show up on the web page yet.  To update this, we need to make the system re-index the files.  To save time, be as specific as possible about where you want to re-index.  In the example below we re-index all files in the administrator’s folder, however extending the filepath will target this command to only re-index the folders you want it to.

sudo -u www-data php /var/www/html/nextcloud/occ files:scan –path=”/administrator/files”

Alternatively, you can navigate to content.ct-networks.com/filescan.php

The files will now appear on the web pages.

Finally, unmount the USB drive so it can be removed.
umount /dev/sdd2


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *