Terminating an Upload

An ongoing or suspended file upload can be manually terminated. Once terminated, you will not be able to resume the upload.

The following sample code shows how to terminate an upload.

  • // Assume that "uploader" handles the ongoing or suspended upload.
    
    try {
      // Terminate uploading.
      uploader.terminate();
    } catch (NoEntryException e) {
      // The uploader was not found. Most likely the upload has already been completed.
    } catch (StateStoreAccessException e) {
      // Failed to access the local storage.
    }
  • // Assume that "uploader" handles the ongoing or suspended upload.
    
    // Terminate uploading.
    uploader.terminateAsync(new KiiRTransferCallback() {
      @Override
      public void onTerminateCompleted(KiiRTransfer operator, Exception exception) {
        if (exception != null) {
          // Handle the error.
          return;
        }
      }
    });

Call the terminate() method to terminate an upload. An error will be returned if you attempt to terminate a finished upload.