PCloudClient
public final class PCloudClient
                Utility class providing convenient interface to common API methods.
- 
                  
                  
The underlying builder responsible for creating call tasks.
Declaration
Swift
public let callTaskBuilder: PCloudAPICallTaskBuilder - 
                  
                  
The underlying builder responsible for creating upload tasks.
Declaration
Swift
public let uploadTaskBuilder: PCloudAPIUploadTaskBuilder - 
                  
                  
The underlying builder responsible for creating download tasks.
Declaration
Swift
public let downloadTaskBuilder: PCloudAPIDownloadTaskBuilder - 
                  
                  
Initializes a new instance.
Declaration
Swift
public init(callTaskBuilder: PCloudAPICallTaskBuilder, uploadTaskBuilder: PCloudAPIUploadTaskBuilder, downloadTaskBuilder: PCloudAPIDownloadTaskBuilder)Parameters
callTaskBuilderWill be used to create call tasks.
uploadTaskBuilderWill be used to create upload tasks.
downloadTaskBuilderWill be used to create download tasks.
 - 
                  
                  
Creates and returns a task for fetching user metadata.
Return Value
A task producing a
User.Metadataobject on success. - 
                  
                  
Creates and returns a task for fetching folder metadata along with metadata of its contents.
Declaration
Parameters
folderIdThe unique identifier of the folder to fetch.
recursivePass
falseto fetch only the immediate children of the folder. Passtrueto fetch the full folder tree of the folder.Return Value
A task producing a
Folder.Metadataobject on success. - 
                  
                  
Creates and returns a task for creating a folder.
Declaration
Parameters
nameA name for the new folder.
folderIdThe unique identifier of the parent folder.
Return Value
A task producing a
Folder.Metadataobject on success. - 
                  
                  
Creates and returns a task for renaming a folder.
Declaration
Parameters
folderIdThe unique identifier of the folder to rename.
newNameThe new name for the folder.
Return Value
A task producing a
Folder.Metadataobject on success. - 
                  
                  
Creates and returns a task for moving a folder.
Declaration
Parameters
folderIdThe unique identifier of the folder to move.
destinationFolderIdThe unique identifier of the destination folder.
Return Value
A task producing a
Folder.Metadataobject on success. - 
                  
                  
Creates and returns a task for copying a folder.
Declaration
Parameters
folderIdThe unique identifier of the folder to copy.
destinationFolderIdThe unique identifier of the destination folder.
Return Value
A task producing a
Folder.Metadataobject on success. - 
                  
                  
Creates and returns a task for uploading a file from a
Dataobject.Declaration
Swift
public func upload(_ data: Data, toFolder folderId: UInt64, asFileNamed name: String, withModificationDate date: Date? = nil) -> UploadTask<PCloudAPI.UploadFile>Parameters
dataThe data to upload.
folderIdThe unique identifier of the parent folder.
nameA name for the file.
dateThe date to use as the modification date for the file when creating it in the file system. Passing
nilwill create the file with the current date as the modification date.Return Value
A task producing a
File.Metadataobject on success. - 
                  
                  
Creates and returns a task for uploading a file from a local file.
Declaration
Swift
public func upload(fromFileAt path: URL, toFolder folderId: UInt64, asFileNamed name: String, withModificationDate date: Date? = nil) -> UploadTask<PCloudAPI.UploadFile>Parameters
pathThe local path of the file to upload.
folderIdThe unique identifier of the parent folder.
nameA name for the file.
dateThe date to use as the modification date for the file when creating it in the file system. Passing
nilwill create the file with the current date as the modification date.Return Value
A task producing a
File.Metadataobject on success. - 
                  
                  
Creates and returns a task for creating an upload session. The upload identifier produced by this method can be used to upload a file over multiple requests.
Return Value
A task producing an upload identifier (
UInt64value) on success. - 
                  
                  
Creates and returns a task for fetching the current state of an upload session.
Declaration
Parameters
uploadIdAn upload identifier.
Return Value
A task producing an
UploadInfoinstance on success. - 
                  
                  
Creates and returns a task for writing the data of a local file to an upload session.
Declaration
Swift
public func upload(fromFileAt path: URL, toUpload uploadId: UInt64, atOffset offset: UInt64) -> UploadTask<PCloudAPI.WriteToUpload>Parameters
pathThe local path of the file to upload.
uploadIdAn upload identifier.
offsetThe upload session offset at which to start writing.
 - 
                  
                  
Creates and returns a task for writing a
Datainstance to an upload session.Declaration
Swift
public func upload(_ data: Data, toUpload uploadId: UInt64, atOffset offset: UInt64) -> UploadTask<PCloudAPI.WriteToUpload>Parameters
dataThe data to write.
uploadIdAn upload identifier.
offsetThe upload session offset at which to start writing.
 - 
                  
                  
Creates and returns a task for save an upload session as a file in the file system.
Declaration
Parameters
idAn identifier of the upload session to save.
parentFolderIdThe identifier folder in which to save the file.
nameThe file name to use when saving. Note this might change depending on the conflict resolution.
onConflictAn action to take if a file conflict occurs. Please see
PCloudAPI.SaveUploadfor more info.Return Value
A task producing a
File.Metadatainstance on success. - 
                  
                  
Creates and returns a task for copying a file.
Declaration
Parameters
fileIdThe unique identifier of the file to copy.
destinationFolderIdThe unique identifier of the destination folder.
overwriteWhether to overwrite (
true) a file with the same name in the destination folder, or to fail (false, the default).Return Value
A task producing a
File.Metadataobject on success. - 
                  
                  
Creates and returns a task for renaming a file.
Declaration
Parameters
fileIdThe unique identifier of the file to rename.
nameThe new name for the file.
Return Value
A task producing a
File.Metadataobject on success. - 
                  
                  
Creates and returns a task for moving a file.
Declaration
Parameters
fileIdThe unique identifier of the file to move.
destinationFolderIdThe unique identifier of the destination folder.
Return Value
A task producing a
File.Metadataobject on success. - 
                  
                  
Creates and returns a task for deleting a file.
Parameters
fileIdThe unique identifier of the file to delete.
Return Value
A task producing a
File.Metadataobject on success. - 
                  
                  
Creates and returns a task for generating a link from which a file can be downloaded.
Declaration
Parameters
fileIdThe unique identifier of the file.
Return Value
A task producing an
Array<FileLink.Metadata>object on success. - 
                  
                  
Creates and returns a task for generating a link from which a thumbnail for a file can be downloaded. Only files with
hasThumbnailset totruecan have thumbnail links generated.Declaration
Parameters
fileIdThe unique identifier of the file.
thumbnailSizeThe required size of the thumbnail. The width must be between 16 and 2048. The height must be between 16 and 1024. And both width and height must be divisible by either 4 or 5
forceExactThumbnailSizeWhether to enforce
thumbnailSize(true) by potentially cropping parts of the image, or to allow width or height (but not both) to be smaller than the requested size. Aspect ratio is always preserved.Return Value
A task producing an
Array<FileLink.Metadata>object on success. - 
                  
                  
Creates and returns a task for generating thumbnail links for multiple files. Logically equivalent to calling
getThumbnailLink()for multiple files. Only files withhasThumbnailset totruecan have thumbnail links generated.Declaration
Parameters
fileIdsA set of unique file identifiers to generate thumbnail links for.
thumbnailSizeThe required size of the thumbnail. The width must be between 16 and 2048. The height must be between 16 and 1024. And both width and height must be divisible by either 4 or 5
forceExactThumbnailSizeWhether to enforce
thumbnailSize(true) by potentially cropping parts of the images, or to allow width or height (but not both) to be smaller than the requested size. Aspect ratio is always preserved.Return Value
A task producing a
Dictionary<UInt64, Result<Array<FileLink.Metadata>, Error>>object on success. The keys in the dictionary are the file identifiers passed as input to this method. Each file identifier is mapped against the result of aquiring a thumbnail link for that file. - 
                  
                  
Creates and returns a task for downloading a file from a
URL.Declaration
Swift
public func downloadFile(from address: URL, downloadTag: String? = nil, to destination: @escaping (URL) throws -> URL) -> DownloadTaskParameters
addressThe resource address.
downloadTagTo be passed alongside
FileLink.Metadataresource addresses. Authenticates this client to the storage servers.destinationA block called with the temporary location of the downloaded file on disk. The block must either move or open the file for reading before it returns, otherwise the file gets deleted. The block should return the new location of the file.
Return Value
A task producing a
URLon success which is the local path of the downloaded file. 
View on GitHub
        PCloudClient Class Reference