Class UploadRequest<T extends Payload>

java.lang.Object
com.cloudinary.android.UploadRequest<T>
Type Parameters:
T - The payload type this request will upload

public class UploadRequest<T extends Payload>
extends java.lang.Object
A request to upload a single Payload to Cloudinary. Note: Once calling dispatch() the request is sealed and any attempt to modify it will produce an IllegalStateException. If there's a need to change a request after dispatching, it needs to be cancelled (MediaManager.cancelRequest(String)) and a new request should be dispatched in it's place.
  • Constructor Details

  • Method Details

    • callback

      public UploadRequest<T> callback​(UploadCallback callback)
      Setup a callback to get notified on upload events.
      Returns:
      This request for chaining.
    • unsigned

      public UploadRequest<T> unsigned​(java.lang.String uploadPreset)
      Make this an unsigned upload
      Parameters:
      uploadPreset - The name of the upload preset to use, as defined in your cloudinary console
      Returns:
      This request for chaining.
    • maxFileSize

      public UploadRequest<T> maxFileSize​(long bytes)
      Fail the request is the file size is larger than this
      Parameters:
      bytes - Maximum allowed file size to upload
      Returns:
      This request for chaining
    • preprocess

      public UploadRequest<T> preprocess​(PreprocessChain preprocessChain)
      Add a chain of preprocessing step to run on the resource before uploading
      Parameters:
      preprocessChain - Preprocess chain to run on the file before the upload
      Returns:
      This request for chaining.
    • constrain

      public UploadRequest<T> constrain​(TimeWindow timeWindow)
      Constrain this request to run within a specific TimeWindow.
      Returns:
      This request for chaining.
    • options

      public UploadRequest<T> options​(java.util.Map<java.lang.String,​java.lang.Object> options)
      Set a map of options for this request. Note: This replaces any existing options.
      Returns:
      This request for chaining.
    • option

      public UploadRequest<T> option​(java.lang.String name, java.lang.Object value)
      Add an option to this request.
      Parameters:
      name - Option name.
      value - Option value.
      Returns:
      This request for chaining.
    • policy

      public UploadRequest<T> policy​(UploadPolicy policy)
      Set the upload uploadPolicy for the request
      Parameters:
      policy - The uploadPolicy to set. See UploadPolicy.Builder
      Returns:
      This request for chaining.
    • dispatch

      public java.lang.String dispatch()
      Dispatch the request
      Returns:
      The unique id of the request.
    • startNow

      public java.lang.String startNow​(@NonNull android.content.Context context)
      Start the request immediately, ignoring all other constraints.
      Parameters:
      context - Android context
      Returns:
      The started request id.
    • dispatch

      public java.lang.String dispatch​(@Nullable android.content.Context context)
      Dispatch the request
      Parameters:
      context - Android context. Needed if using preprocessing. Otherwise can be null.
      Returns:
      The unique id of the request.
    • getRequestId

      public java.lang.String getRequestId()
    • getPayload

      public T getPayload()