nx_server_plugin_sdk 1.0 Server Plugin SDK

Classes | Namespaces | Typedefs
ftp_library.h File Reference
`#include <atomic>`
`#include <memory>`
`#include <mutex>`
`#include <stdexcept>`
`#include <string>`
`#include <vector>`
`#include <stdint.h>`
`#include "ftplibpp/ftplib.h"`
`#include "storage/third_party_storage.h"`

Go to the source code of this file.

## Classes
class | nx_spl::aux::PluginRefCounter< P >
class | nx_spl::aux::NonCopyable
struct | nx_spl::aux::FileNameAndPath
class | nx_spl::FtpIODevice
class | nx_spl::FtpFileInfoIterator
class | nx_spl::FtpStorage
class | nx_spl::FtpStorageFactory

## Namespaces
| nx_spl
| Storage plugin namespace.

## Typedefs
using | nx_spl::FtpImplPtr = std::shared_ptr< aux::FtpLibWrapper >

## Detailed Description

This is the example project aimed to demonstrate a possible implementation of a Storage plugin.

- nx_spl::StorageFactory::createStorage() function will receive url to base folder. For example: `ftp://10.10.2.54/some/path`
- All other API functions which have URL parameter will receive URL without scheme and host. For example: `/some/path/folder1/folder2`
- In FileInfoIterator::next() the plugin should provide full URL to target location (with or without scheme + host). For example:

          fileInfo.url = ftp://10.10.2.54/some/path/file1.mkv // right
          fileInfo.url = /some/path/file1.mkv // right
          fileInfo.url = file1.mkv // wrong

- Some of the API functions are called frequently, for example open(), some - based on some (sometimes quite long) timeout, for example, removeDir(). But the Server calls all of them in time, so every function should be implemented correctly.
- For some storages types, for example FTP, it may be impossible to 'honestly' implement such functions as getTotalSpace() and getFreeSpace(). In this case these functions are allowed to return some sensible constant value. Keep in mind that getTotalSpace() is used mainly in determining "best" storage algorithm. For example if some storage total space is far smaller than others this storage won't be selected for writing. Or if some storage is twice larger than another, it will be written on twice more data. Also total space value is displayed in client for every storage in list. getFreeSpace() is used to rotate data on storages. If the Server sees that some storage free space becomes lower than predefined limit (5 GB by default) it will try to remove some old files and folders on this storage.

Usage of the plugin:

Connect to the Server with a Client. In external storage selection dialog you should be able to see new storage type (FTP). Enter a valid ftp url and credentials and press Ok. For example:

- Url: `ftp://10.2.3.87/path/to/storage`
- Login: `user1`
- Password: `12345678`