net.netheos.pcsapi.storage
Interface IStorageProvider

All Known Implementing Classes:
CloudMe, Dropbox, GoogleDrive, Hubic, StorageProvider

public interface IStorageProvider

Reference interface for storage providers.


Method Summary
 void close()
          Close the provider.
 boolean createFolder(CPath path)
          Create a folder at given path, with intermediate folders if needed.
 boolean delete(CPath path)
          Deletes blob, or recursively delete folder at given path.
 void download(CDownloadRequest downloadRequest)
          Downloads a blob from provider to a byte sink, as defined by the download_request object.
 CFile getFile(CPath path)
          Return detailed file information at given path, or None if no object exists at this path
 String getProviderName()
          Get the provider name
 CQuota getQuota()
          Returns a CQuota object
 String getUserId()
          Return user identifier (login in case of login/password, or email in case of OAuth
 CFolderContent listFolder(CFolder folder)
          Return a map of files present in given CFolder. keys of map are CPath objects, values are CFile objects (CFolder or CBlob).
 CFolderContent listFolder(CPath path)
          Return a map of files present in given CPath. keys of map are CPath objects, values are CFile objects (CFolder or CBlob).
 CFolderContent listRootFolder()
          Equivalent to listFolder(net.netheos.pcsapi.models.CPath) with "/"
 void upload(CUploadRequest uploadRequest)
          Uploads a byte source to provider, as defined by upload_request object.
 

Method Detail

getProviderName

String getProviderName()
Get the provider name

Returns:
The provider name (ie. "dropbox")

getUserId

String getUserId()
                 throws CStorageException
Return user identifier (login in case of login/password, or email in case of OAuth

Returns:
user identifier (login in case of login/password, or email in case of OAuth
Throws:
CStorageException - Error getting the user identifier

getQuota

CQuota getQuota()
                throws CStorageException
Returns a CQuota object

Returns:
a tuple: used bytes, allowed bytes.
Throws:
CStorageException - Error getting the quota

listRootFolder

CFolderContent listRootFolder()
                              throws CStorageException
Equivalent to listFolder(net.netheos.pcsapi.models.CPath) with "/"

Returns:
TODO
Throws:
CStorageException - Error getting the root folder

listFolder

CFolderContent listFolder(CPath path)
                          throws CStorageException
Return a map of files present in given CPath. keys of map are CPath objects, values are CFile objects (CFolder or CBlob). Return None if no folder exists at given path. Raise CInvalidFileTypeError if given path is a blob. Note : objects in returned map may have incomplete information

Parameters:
path - The folder path
Returns:
a map of files present at given CPath. keys of map are CPath objects, values are CFile objects (CFolder or CBlob). Return null if no folder exists at given path. Throws CInvalidFileTypeError if given path is a blob.
Throws:
CStorageException - Error getting the files in the folder

listFolder

CFolderContent listFolder(CFolder folder)
                          throws CStorageException
Return a map of files present in given CFolder. keys of map are CPath objects, values are CFile objects (CFolder or CBlob). Return None if no folder exists at given path. Raise CInvalidFileTypeError if given path is a blob. Note : objects in returned map may have incomplete information

Parameters:
folder - The folder to get the files in
Returns:
a map of files present in given CFolder keys of map are CPath objects, values are CFile objects (CFolder or CBlob). Return null if no folder exists at given path. Note : objects in returned map may have incomplete information.
Throws:
CStorageException - Error getting the files in the folder

createFolder

boolean createFolder(CPath path)
                     throws CStorageException
Create a folder at given path, with intermediate folders if needed. Throws CInvalidFileType error if a blob exists at this path.

Parameters:
path - The folder path to create
Returns:
true if folder has been created, false if it was already existing.
Throws:
CStorageException - Error creating the folder

delete

boolean delete(CPath path)
               throws CStorageException
Deletes blob, or recursively delete folder at given path.

Parameters:
path - The file path to delete
Returns:
true if at least one file was deleted, false if no object was existing at this path.
Throws:
CStorageException - Error deleting the file

getFile

CFile getFile(CPath path)
              throws CStorageException
Return detailed file information at given path, or None if no object exists at this path

Parameters:
path - The file path
Returns:
detailed file information at given path, or null if no object exists at this path
Throws:
CStorageException - Error getting the file

download

void download(CDownloadRequest downloadRequest)
              throws CStorageException
Downloads a blob from provider to a byte sink, as defined by the download_request object. Throws CFileNotFoundError if no blob exists at this path. Throws CInvalidFileTypeError if a folder exists at specified path.

Parameters:
downloadRequest - The download request object
Throws:
CStorageException - Download error

upload

void upload(CUploadRequest uploadRequest)
            throws CStorageException
Uploads a byte source to provider, as defined by upload_request object. If a blob already exists it is replaced. Throws CInvalidFileTypeError if a folder already exists at specified path.

Parameters:
uploadRequest - The upload resuest object
Throws:
CStorageException - Upload error

close

void close()
           throws CStorageException
Close the provider. The internal objets will be released

Throws:
CStorageException - Close error


Copyright © 2014. All Rights Reserved.