#include <Uploader.h>
Public Types | |
enum | Step { scanning, preparing, uploading } |
typedef std::function< void(FileTransferer &, TransferProgress)> | ProgressFct |
typedef std::function< void(const ScannedFile &)> | OnScannedFct |
typedef std::function< void(const PreparedFile &)> | OnPreparedFct |
typedef std::function< void(const boost::filesystem::path &, std::shared_ptr< Node >)> | OnUploadedFct |
typedef std::function< void(const boost::filesystem::path &, std::string &&, Step)> | OnErrorFct |
Public Member Functions | |
Uploader (const Application &app) | |
Construct an Uploader. More... | |
Uploader (Uploader &&)=delete | |
Uploader (const Uploader &)=delete | |
Uploader & | operator= (const Uploader &)=delete |
Uploader & | operator= (Uploader &&)=delete |
void | setUploadProgressFct (ProgressFct fct) |
Set a callback to follow the upload progress. More... | |
void | setPreparationProgressFct (ProgressFct fct) |
Set a callback to follow the preparation process. More... | |
void | setOnScannedFct (OnScannedFct fct) |
void | setOnPreparedFct (OnPreparedFct fct) |
void | setOnUploadedFct (OnUploadedFct fct) |
void | setOnErrorFct (OnErrorFct fct) |
void | addUpload (FolderNode parent, boost::filesystem::path &&path) |
add a file or folder to the list of uploads More... | |
void | addUploads (FolderNode parent, std::vector< boost::filesystem::path > &&pathes) |
void | start () |
start the uploading process | |
void | join () |
wait for the uploading process to finish | |
void | kill () |
cancel the current upload; Clear the queue; stop the process. | |
void | limitRate (uint64_t rate) |
Limit the current upload rate. More... | |
void | pause () |
Pause the current upload. Uses resume() to restart. | |
void | resume () |
Resume a previously pause() d upload. | |
void | clear () |
Remove all the files waiting to be process. Only the current uploading file remains. The Error queue is cleared (. More... | |
FileTransferer::State | state () |
Gets the current upload state. | |
bool | isStarted () const |
FileUploader * | uploadingFile () |
void | callProgressFct () const |
void | addScannedFile (const std::string parentId, const boost::filesystem::path &path) |
void | addPreparedFile (const std::string parentId, const boost::filesystem::path &path, const std::string &sha1) |
Detailed Description
Upload files and folders.
Start the upload process with the Uploader::start()
method. Uses Uploader::addUpload()
to add file/folder to upload. Terminate the uploading process using the Uploader::join()
method.
There are 3 phases in the upload process :
- First the folder to upload is scanned, and every file found will be sent to the preparation process
- Every file to upload needs to get prepared (calculate its sha1 etc...)
- The prepared files gets finally uploaded.
Constructor & Destructor Documentation
|
explicit |
Construct an Uploader.
- See Also
- setUploadProgressFct()
- setPreparationProgressFct()
- setOnNewNodeFct()
Member Function Documentation
void giga::core::Uploader::addUpload | ( | FolderNode | parent, |
boost::filesystem::path && | path | ||
) |
add a file or folder to the list of uploads
- Parameters
-
parent the folder in which we want to upload data path the path to the file or folder we want to upload
void giga::core::Uploader::clear | ( | ) |
Remove all the files waiting to be process. Only the current uploading file remains. The Error queue is cleared (.
- See Also
consumeError()
)
void giga::core::Uploader::limitRate | ( | uint64_t | rate | ) |
Limit the current upload rate.
- Parameters
-
rate the upload rate in Octet/s. Uses 0 for no limit.
void giga::core::Uploader::setOnErrorFct | ( | OnErrorFct | fct | ) |
- Parameters
-
fct will be called for every error/canceled uploads.
void giga::core::Uploader::setOnPreparedFct | ( | OnPreparedFct | fct | ) |
- Parameters
-
fct will be called every time a preparation is finish..
void giga::core::Uploader::setOnScannedFct | ( | OnScannedFct | fct | ) |
- Parameters
-
fct will be called every file found in the folders to upload
For each file/folder passed to addUpload()
, the fct
gets called one extra time, to notify that all files for this addUpload()
have been scanned. In this special case, the ScannedFile::size
is set to zero.
void giga::core::Uploader::setOnUploadedFct | ( | OnUploadedFct | fct | ) |
- Parameters
-
fct will be called for every node created (file or folder) during the upload process.
void giga::core::Uploader::setPreparationProgressFct | ( | ProgressFct | fct | ) |
Set a callback to follow the preparation process.
- Parameters
-
fct a callback function that will be called periodically to let you know of the progress of the preparation process (mostly sha1 calculation).
fct
will be called at least once for each file being prepared. You should not do any long lasting computation in this function.
void giga::core::Uploader::setUploadProgressFct | ( | ProgressFct | fct | ) |
Set a callback to follow the upload progress.
- Parameters
-
fct a callback function that will be called periodically to let you know of the upload progress
fct
will be called :
- At the beginning of the upload for each file
- For long upload it is called periodically.
You should not do any long lasting computation in this function.
The documentation for this class was generated from the following files:
- /home/thomas/code/GiGaSdk/src/giga/core/Uploader.h
- /home/thomas/code/GiGaSdk/src/giga/core/Uploader.cpp