Class KiiUploader
- java.lang.Object
-
- com.kii.cloud.storage.resumabletransfer.KiiUploader
-
- All Implemented Interfaces:
KiiRTransfer
public abstract class KiiUploader extends java.lang.Object implements KiiRTransfer
Provide apis uploading file with resumable transfer. Transition of file upload status is bellow.
Upload status will be stored in persistent storage. To manage suspended uploads, refer toKiiRTransferManager
-
-
Constructor Summary
Constructors Constructor Description KiiUploader()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract FileHolder
getFileHolder()
Get the FileHolder of this uploader.
ex.) If uploader initiated byKiiObject.uploader(android.content.Context, File)
, KiiObject instance is the actual FileHolder.abstract java.io.File
getSourceFile()
Get the source file of this uploader.abstract KiiRTransferInfo
info()
Get the status of the upload.abstract void
infoAsync(KiiRTransferCallback callback)
Asynchronous call ofinfo()
.abstract void
suspend()
Suspend current running upload.abstract void
suspendAsync(KiiRTransferCallback callback)
Asynchronous call ofsuspend()
.abstract void
terminate()
Terminate running/ suspended upload.abstract void
terminateAsync(KiiRTransferCallback callback)
Asynchronous call ofterminate()
.abstract void
transfer(KiiRTransferProgressCallback progress)
Start upload file and wait for completion.abstract void
transferAsync(KiiRTransferCallback callback)
Asynchronous call oftransfer(KiiRTransferProgressCallback)
.
-
-
-
Method Detail
-
getSourceFile
@NonNull public abstract java.io.File getSourceFile()
Get the source file of this uploader.- Returns:
- local source file
-
getFileHolder
@Nullable public abstract FileHolder getFileHolder()
Get the FileHolder of this uploader.
ex.) If uploader initiated byKiiObject.uploader(android.content.Context, File)
, KiiObject instance is the actual FileHolder.- Specified by:
getFileHolder
in interfaceKiiRTransfer
- Returns:
- FileHolder of this uploader.
-
transfer
public abstract void transfer(@Nullable KiiRTransferProgressCallback progress) throws AlreadyStartedException, SuspendedException, TerminatedException, StateStoreAccessException
Start upload file and wait for completion. If the suspended entry has exist for the file, automatically try to resume. otherwise start new uploading.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Specified by:
transfer
in interfaceKiiRTransfer
- Parameters:
progress
- can be null. If provided, progress information will be notified.- Throws:
AlreadyStartedException
- when the upload has already started for the file.SuspendedException
- upload has suspended. mostly network error or suspended bysuspend()
orsuspendAsync(KiiRTransferCallback)
TerminatedException
- upload has terminated due to the error orterminate()
orterminateAsync(KiiRTransferCallback)
has called. Stored status of the upload will be cleared. Mostly the error would be for following reasons:
- target bucket/ file holder on cloud has deleted
- The source file has been modified.In this case, calling
transfer(KiiRTransferProgressCallback)
ortransferAsync(KiiRTransferCallback)
again upload the modified file from the beginning.StateStoreAccessException
- thrown when failed to access the persistent storage stores transfer state. (ex. Disk full, etc.) The upload will be suspended and you can retry safely.- See Also:
KiiRTransferProgressCallback
,transferAsync(KiiRTransferCallback)
-
transferAsync
public abstract void transferAsync(@Nullable KiiRTransferCallback callback)
Asynchronous call oftransfer(KiiRTransferProgressCallback)
.
NOTE: This method should be executed in UI thread.- Specified by:
transferAsync
in interfaceKiiRTransfer
- Parameters:
callback
- can be null. If provided, notifies event (start, completion, cancelled, etc.)- See Also:
transfer(KiiRTransferProgressCallback)
,KiiRTransferProgressCallback
,KiiRTransferCallback
-
suspend
public abstract void suspend() throws NoEntryException, StateStoreAccessException
Suspend current running upload. If already suspended, do nothing.
NOTE: This api access to internal file storage stores status of upload . Should not be executed in UI/Main thread.- Specified by:
suspend
in interfaceKiiRTransfer
- Throws:
NoEntryException
- thrown when the upload has finished or not started.StateStoreAccessException
- thrown when failed to access the persistent storage stores transfer state. (ex. Disk full, etc.) suspend will be failed.- See Also:
NoEntryException
,suspendAsync(KiiRTransferCallback)
-
suspendAsync
public abstract void suspendAsync(@Nullable KiiRTransferCallback callback)
Asynchronous call ofsuspend()
.
NOTE: This method should be executed in UI thread.- Specified by:
suspendAsync
in interfaceKiiRTransfer
- Parameters:
callback
- can be null. If provided, notifies event.- See Also:
suspend()
,KiiRTransferCallback
-
terminate
public abstract void terminate() throws NoEntryException, StateStoreAccessException
Terminate running/ suspended upload. The entry will be removed. after termination, uploading same file would start from beginning.
NOTE: This api access to internal file storage stores status of upload . Should not be executed in UI/Main thread.- Specified by:
terminate
in interfaceKiiRTransfer
- Throws:
NoEntryException
- thrown when the upload has not started yet or already done.StateStoreAccessException
- thrown when failed to access the persistent storage stores transfer state. (ex. Disk full, etc.) ongoing upload will be cancelled but failed to remove the entry in the storage. The state will be transit to suspended.- See Also:
terminateAsync(KiiRTransferCallback)
-
terminateAsync
public abstract void terminateAsync(@Nullable KiiRTransferCallback callback)
Asynchronous call ofterminate()
.
NOTE: This method should be executed in UI thread.- Specified by:
terminateAsync
in interfaceKiiRTransfer
- Parameters:
callback
- can be null. If provided, notifies event.- See Also:
terminate()
,KiiRTransferCallback
-
info
@NonNull public abstract KiiRTransferInfo info() throws StateStoreAccessException
Get the status of the upload.
NOTE: This api access to internal file storage stores status of upload . Should not be executed in UI/Main thread.- Specified by:
info
in interfaceKiiRTransfer
- Returns:
- KiiRTransferInfo represents status of upload
- Throws:
StateStoreAccessException
- Thrown when failed to access persistent storage stores transfer state. (ex. Disk full, etc.)
You can retry safely.- See Also:
KiiRTransferInfo
,infoAsync(KiiRTransferCallback)
-
infoAsync
public abstract void infoAsync(@NonNull KiiRTransferCallback callback)
Asynchronous call ofinfo()
.
NOTE: This method should be executed in UI thread.- Specified by:
infoAsync
in interfaceKiiRTransfer
- Parameters:
callback
- Notifies events. Can not be null.- Throws:
java.lang.IllegalArgumentException
- when the callback is null.- See Also:
info()
,KiiRTransferCallback
-
-