Class LargeFileUploadTask<T extends com.microsoft.kiota.serialization.Parsable>

java.lang.Object
com.microsoft.graph.core.tasks.LargeFileUploadTask<T>
Type Parameters:
T - They type of Item that we will be uploading

public class LargeFileUploadTask<T extends com.microsoft.kiota.serialization.Parsable> extends Object
Task for uploading large files including pausing and resuming.
  • Constructor Details

    • LargeFileUploadTask

      public LargeFileUploadTask(@Nullable com.microsoft.kiota.RequestAdapter requestAdapter, @Nonnull com.microsoft.kiota.serialization.Parsable uploadSession, @Nonnull InputStream uploadStream, long streamSize, @Nonnull com.microsoft.kiota.serialization.ParsableFactory<T> factory) throws IllegalAccessException, IOException, InvocationTargetException, NoSuchMethodException
      LargeFileUploadTask instance constructor.
      Parameters:
      requestAdapter - The request adapter for this upload task.
      uploadSession - Parsable containing upload session information.
      uploadStream - Readable stream of information to be uploaded.
      streamSize - The size of the information stream to be uploaded.
      factory - The ParsableFactory defining the instantiation of the object being uploaded.
      Throws:
      IllegalAccessException - thrown when attempting to extract uploadSession information.
      IOException - thrown when attempting to extract uploadSession information.
      InvocationTargetException - thrown when attempting to extract uploadSession information.
      NoSuchMethodException - thrown when attempting to extract uploadSession information.
    • LargeFileUploadTask

      public LargeFileUploadTask(@Nullable com.microsoft.kiota.RequestAdapter requestAdapter, @Nonnull com.microsoft.kiota.serialization.Parsable uploadSession, @Nonnull InputStream uploadStream, long streamSize, long maxSliceSize, @Nonnull com.microsoft.kiota.serialization.ParsableFactory<T> factory) throws IllegalAccessException, IOException, InvocationTargetException, NoSuchMethodException
      LargeFileUploadTask instance constructor.
      Parameters:
      requestAdapter - The request adapter for this upload task.
      uploadSession - Parsable containing upload session information.
      uploadStream - Readable stream of information to be uploaded.
      streamSize - The size of the information stream to be uploaded.
      maxSliceSize - Max size(in bytes) of each slice to be uploaded. Defaults to 5 MB. When uploading to OneDrive or SharePoint, this value needs to be a multiple of 320 KiB (327,680 bytes).
      factory - The ParsableFactory defining the instantiation of the object being uploaded.
      Throws:
      IllegalAccessException - thrown when attempting to extract uploadSession information.
      IOException - thrown when attempting to extract uploadSession information.
      InvocationTargetException - thrown when attempting to extract uploadSession information.
      NoSuchMethodException - thrown when attempting to extract uploadSession information.
  • Method Details

    • upload

      @Nonnull public UploadResult<T> upload() throws IOException, InterruptedException
      Perform the upload task.
      Returns:
      An UploadResult model containing the information from the server resulting from the upload request. May also occur if interruption occurs in .sleep() call.
      Throws:
      IOException - if there was an error reading the chunk input stream.
      InterruptedException - if the thread is interrupted while sleeping.
    • upload

      @Nonnull public UploadResult<T> upload(int maxTries, @Nullable IProgressCallback progress) throws IOException, InterruptedException
      Perform the upload task.
      Parameters:
      maxTries - Number of times to retry the task before giving up.
      progress - IProgress interface describing how to report progress.
      Returns:
      An UploadResult model containing the information from the server resulting from the upload request. May also occur if interruption occurs in .sleep() call.
      Throws:
      IOException - if there was an error reading the chunk input stream.
      InterruptedException - if the thread is interrupted while sleeping.
    • resume

      @Nonnull public UploadResult<T> resume() throws ClientException, IOException, InterruptedException
      Resume the upload task.
      Returns:
      An UploadResult model containing the information from the server resulting from the upload request.
      Throws:
      ClientException - if the upload session has expired.
      IOException - if there was an error reading the chunk input stream.
      InterruptedException - if the thread is interrupted while sleeping.
    • resume

      @Nonnull public UploadResult<T> resume(int maxTries, @Nullable IProgressCallback progress) throws ClientException, IOException, InterruptedException
      Resume the upload task.
      Parameters:
      maxTries - Number of times to retry the task before giving up.
      progress - IProgress interface describing how to report progress.
      Returns:
      An UploadResult model containing the information from the server resulting from the upload request.
      Throws:
      ClientException - if the upload session has expired.
      IOException - if there was an error reading the chunk input stream.
      InterruptedException - if the thread is interrupted while sleeping.
    • deleteSession

      public void deleteSession() throws ClientException
      Delete the upload session.
      Throws:
      ClientException - if the upload session has expired.
    • updateSessionStatus

      @Nonnull public IUploadSession updateSessionStatus()
      Get the session information from the server, and update the internally held session with the updated information.
      Returns:
      the updated UploadSession model.
    • getUploadSliceRequests

      @Nonnull protected List<UploadSliceRequestBuilder<T>> getUploadSliceRequests()
      Creates the UploadSliceRequestBuilders for the upload task based on the upload session information.
      Returns:
      The list of UploadSliceRequestsBuilders, each describing a slice to be uploaded.