Working with Nextcloud

Updated 29 April 2020

Working with Netcloud

Introduction

This article summarizes information on working with Nextcloud, as well as on integration with third-party cloud services. Please refer to this manual to install Netcloud.

Fixes

Contact picture update

For a long time there had been an annoying bug: impossible to replace the uploaded photo of a contact. When you click on a previously uploaded photo, it opens instead of prompting for a new picture to be selected.

To fix this, do as described below.

  1. Log in to Nextcloud as the administrator, go to Menu -> Applications and install Custom CSS.
  2. Now go to Menu -> Settings -> Themes. Fill in the "Custom CSS" field with the following:
    ```
    .contact-header-avatar__photo + .contact-header-avatar__options {
    z-index: 1;
    }

    .contact-header-avatar__photo + .contact-header-avatar__options {
    opacity: 0;
    }
    ```Now clicking on the photo will open an image upload menu:

Contact picture update

Optimizing Nextcloud

Background task processing

For better performance, all data processing operations should be scheduled to be performed in the background. By default, Nextcloud suggests running cron.php every 15 minutes. This can be adjusted in Settings -> Admin -> Basic parameters. In Background tasks, select Cron:

Background tasks in Nextcloud

Then create a script that will run cron on the background every 15 minutes:

/etc/cron.d/nextcloud

# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/

#Nextcloud
*/15 * * * * nginx php -f /var/calculate/www/nextcloud/htdocs/cron.php

Files

File preview

File types

Like most file managers, Nextcloud can create thumbnails for pictures, video and audio files, text documents, and more. Learn more here. To add a preview for video files, turn it on for all types of pictures in the configuration file of the project:

/var/calculate/www/nextcloud/htdocs/config/config.php

'enabledPreviewProviders' => array (
    'OC\\Preview\\Movie',
    'OC\\Preview\\Image'
),

To improve image performance and compatibility, install imagemagick for PHP:

emerge -a dev-php/pecl-imagick

To extract previews from video files, install ffmpeg:

emerge -a media-video/ffmpeg

Size

It seems reasonable to limit the maximum size, otherwise all your images will be cached in their original size. To do so, add the following lines:

/var/calculate/www/nextcloud/htdocs/config/config.php

'preview_max_x' => 512,
'preview_max_y' => 512,

Cache update

For faster access to directories containing preview files, keep the cache up to date with [Preview Generator] (https://github.com/rullzer/previewgenerator), which can be installed from the "Multimedia" section of the Nextcloud menu.

Once installation completed, run:

su nginx -s /bin/bash

cd /var/calculate/www/nextcloud/htdocs

php occ preview:generate-all

If you have many image files in one directory, you may need to increase the size of RAM allocated to run PHP. To do this, edit the value of memory_limit:

/etc/php/cli-php7.1/php.ini

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 512M

File naming

By default, the Nextcloud client loads the camera pictures in one dedicated directory on the cloud, The names of the pictures look like IMG_20180806_124329_1.jpg, where "20180806" is the year, month and day, "124329", hours, minutes and seconds, and "1" the second photo taken in the same second.

Pictures imported from social networks may of course have random names, something like "MY0bLxxnxTaM.jpg". If it is actually a photo, not a drawing or a screenshot, you can extract the time from the EXIF data of the file. To do so, use the exiv2 utility, included in media-gfx/exiv2:

exiv2 -F -r'IMG_%Y%m%d_%H%M%S' rename -- *.jpg

To check all pics, you can replace the path for the renamed:

mkdir new; exiv2 -F -r'new/IMG_%Y%m%d_%H%M%S' rename -- *.jpg

As a result, there may remain screenshots and processed photos in the source directory, which you can easily separate from the original pictures.

This naming has several advantages.

  1. If you merge photos from different cameras or memory cards, you will probably never come across two identical names, so it will be possible to easily transfer files to a directory after processing.
  2. Photos will always be arranged in chronological order. You can put photos from different sources in one place.
  3. This means that once you have merged in a directory, you will have no duplicates, and all images with reduced resolution will be correctly replaced by originals.

If the file extension is capitalized, you can lower case it with the following command:

rename .JPG .jpg *.JPG

File creation date and time

When you copy photos, the file modification time may change. This is embarrassing, as the time information is lost. It is possible to restore the time based on EXIF data. Use the exiv2 tool. To fetch the time data, go to the pictures directory and run:

exiv2 -T *.jpg

Update the database for the changes to take effect.

A viewer for Android

To manage your photos stored on Nextcloud, you can install the QuickPic gallery application.

Music

An audio player for Android

To play music your files stored on Nextcloud you can use the Soumi: Network Music Player. The player has the advantage of caching audio files on the playlist.

To connect to the cloud, click on the Libraries tab, then on "+" and select Internet. Now log in:

Connect to Nextcloud

Note

The server address should be entered without "https://" but with the path pointing to webdav, such as in cloud.example.org/remote.php/webdav.

A player window looks somewhat like this:

Soumi: Network Music Player

Site password storage

We recommend Passman for storing passwords in Nextcloud. Helpfully, it provides encrypted storage on your cloud. Several storages of this type can be used simultaneously. For interaction with the password storage, you can use the password storage extensions developed for Firefox (including the mobile version) and Chrome. When you join the cloud, you create a password for encryption of connection data:

Passman

Passman looks for authorization fields on the site and adds its icon to them. If you have a saved password, the fields will be filled automatically. See on the screenshot below:

Authenticate

Page bookmarks

To work with bookmarks in Nextcloud, use the Bookmarks application. Instead of the usual tree structure, it uses tags to find bookmarks. To access your bookmarks, you can install the [FreedomMarks] extension (https://github.com/damko/freedommarks-browser-webextension) for [Firefox] (https://addons.mozilla.org/ru/firefox/addon/freedommarks/?src) and [Chrome] (https://chrome.google.com/webstore/detail/freedommarks/gmmpjoepfelkmeedfkfkadgkhholibko):

FreedomMarks

If you are an Android user, you can also use [Nextcloud Bookmarks] (https://play.google.com/store/apps/details?id) to access your bookmarks. It also uses tags.

If you stick to the classic approach to storing bookmarks, you can use the floccus extension. This extension adds its tag to each tab, together with the nesting level.

GPS navigation

To handle GPS navigation, use [ PhoneTrack ] (https://apps.nextcloud.com/apps/phonetrack), which allows you to import routes from .gpx gpx, так и отслеживать положение устройств в режиме реального времени.

PhoneTrack configuration

It is possible to combine all the devices which you want to receive data from into groups, or sessions. A session will be created. Device reservation is required afterwards.

PhoneTrack

As you can see on the screen, a group named Family was created, where three devices with a name and a marker are reserved.

Click on the next tab to see a list of URLs for real-time data transfer. There is an exclamation point next to each option. Click on it to get the link. It must be specified in the interface on the device, using the relevant device marker.

PhoneTrack

Below a GPS Logger configuration is described as an example.

GPS logger configuration

GPS Logger saves routes to a .gpx filegpx и передавать их как в ручном режиме, так и автоматически. The coordinates can be transmitted in real time.

To send in real time, go to Log Record Settings - Save logs to user specified URL and enter the URL address, replacing yourname by the relevant device.

GPS Logger

To verify, run HTTP Test and check the logs.

GPS Logger

GPS Logger

On the screenshots above, you can see the successful test results and the log record confirming that the coordinates were detected and sent to the corresponding address.

The data is written to the database you are using, so that the device will immediately appear in the list as a colored circle filled with the first letter of the device name.

Note

If the device does not have an Internet connection, the coordinates will be sent once the connection is established.

Video/audio conference

Nextcloud allows you to organize chats, as well as audio and/or video conferences via WebRTC. To do this, you will need to install and run Talk. If you expect to have conferences with participants on different networks, and even more so if they are behind a symmetric NAT, you will need a TURN/STUN server.

TURN server configuration

Configure turn.example.org~, your TURN server as shown in the manual.

Now open the Talk settings and specify turn.example.org:443 as the STUN server, turn.example.org as the TURN server, and 4b85833c7fdf06130bd7398ac9af558b as the key (see static-auth-secret in TURN parameters).

TURN configuration in Nextcloud

Working with office documents

After installing NextCloud, you will be able only to view, to manage and to edit documents in txt format. You can use Collabora Online to handle all document types and extensions.

Collabora Online

Install and configure Collabora Online according to the manual.

Administration

Database reindexing

If you copy/rename files, modify access rights, or edit files directly on the server, bypassing the Nextcloud or WebDAV Web interface, you must update the Nextcloud database. Here is how you should do it.

If you have direct access to Nextcloud files (not via WebDAV or the Web interface), be sure to update the files. To so, run:

su nginx -s /bin/bash

cd /var/calculate/www/nextcloud/htdocs

php occ files:scan user

Replace user with your login.

Conclusion

Note

Subscribe to our group @nextcloud@calculate.social in Mastodon