Class DriveFile

java.lang.Object
com.amilesend.onedrive.resource.DriveItemType
com.amilesend.onedrive.resource.DriveFile

public class DriveFile extends DriveItemType
A wrapper around a DriveItem that represents a file.
  • Constructor Details

    • DriveFile

      public DriveFile(DriveItem delegate)
      Creates a new DriveFile that wraps the given getDelegate() DriveItem.
      Parameters:
      delegate - the drive item to wrap
  • Method Details

    • isAudio

      public boolean isAudio()
      Describes if this is an audio file.
      Returns:
      true if this file is an audio file; else, false
    • getAudioAttributes

      public Audio getAudioAttributes()
      Gets the audio file attributes. Can be null.
      Returns:
      the audio file attributes
      See Also:
    • isImage

      public boolean isImage()
      Describes if this is an image file.
      Returns:
      true if this file is an image file; else, false
    • getImageAttributes

      public Image getImageAttributes()
      Gets the image file attributes. Can be null.
      Returns:
      the image file attributes
      See Also:
    • isLocationAvailable

      public boolean isLocationAvailable()
      Determines if there is geolocation attributes for this file.
      Returns:
      true if this file has location attributes; else, false
    • getLocationAttributes

      public GeoCoordinates getLocationAttributes()
      Gets the location attributes (e.g., photo taken from a cell phone). Can be null.
      Returns:
      the location file attributes
      See Also:
    • isPhoto

      public boolean isPhoto()
      Describes if this has photo attributes. Can be null.
      Returns:
      true if this file contains photo attributes; else, false
    • getPhotoAttributes

      public Photo getPhotoAttributes()
      Gets the photo attributes (e.g., photo taken from a cell phone). Can be null.
      Returns:
      the photo attributes
      See Also:
    • isVideo

      public boolean isVideo()
      Describes if this is a video file.
      Returns:
      true if this file is a video file; else, false
    • getVideoAttributes

      public Video getVideoAttributes()
      Gets the vidoe file attributes. Can be null.
      Returns:
      the video file attributes
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • download

      public void download(Path folderPath)
      Downloads this file to the given folderPath.
      Parameters:
      folderPath - the folder to download the file to
    • download

      public void download(Path folderPath, com.amilesend.client.connection.file.TransferProgressCallback callback)
      Downloads this file to the given folderPath and reports transfer progress to the specified TransferProgressCallback.
      Parameters:
      folderPath - the folder to download the file to
      callback - the callback be notified of transfer progress
      See Also:
      • TransferProgressCallback
    • downloadAsync

      public DriveFileDownloadExecution downloadAsync(Path folderPath)
      Downloads this file asynchronously to the given folderPath. Consumers can block on transfer completion by invoking DriveFileDownloadExecution.get() ()}.
      Parameters:
      folderPath - the folder to download the file to
      Returns:
      the asynchronous execution that contains the number of bytes downloaded
      See Also:
    • downloadAsync

      public DriveFileDownloadExecution downloadAsync(Path folderPath, com.amilesend.client.connection.file.TransferProgressCallback callback)
      Downloads this file asynchronously to the given folderPath and reports transfer progress to the specified TransferProgressCallback. Consumers can block on transfer completion by invoking DriveFileDownloadExecution.get().
      Parameters:
      folderPath - the folder to download the file to
      callback - the callback be notified of transfer progress
      Returns:
      the asynchronous execution that contains the number of bytes downloaded
      See Also:
    • upload

      @Deprecated public DriveFile upload(File file) throws IOException
      Deprecated.
      use upload(Path) instead
      Uploads and replaces this drive file's contents with the given file.
      Parameters:
      file - the updated file contents
      Returns:
      a new drive file that represents this updated file
      Throws:
      IOException - if unable to read the file.
      See Also:
    • upload

      public DriveFile upload(Path filePath) throws IOException
      Uploads and replaces this drive file's contents with the given file.
      Parameters:
      filePath - the updated file contents
      Returns:
      a new drive file that represents this updated file
      Throws:
      IOException - if unable to read the file.
      See Also:
    • upload

      @Deprecated public DriveFile upload(File file, com.amilesend.client.connection.file.TransferProgressCallback callback) throws IOException
      Uploads and replaces this drive file's contents with the given file and reports transfer progress to the specified TransferProgressCallback.
      Parameters:
      file - the updated file contents
      callback - the callback be notified of transfer progress
      Returns:
      a new drive file that represents this updated file
      Throws:
      IOException - if unable to read the file.
      See Also:
    • upload

      public DriveFile upload(Path filePath, com.amilesend.client.connection.file.TransferProgressCallback callback) throws IOException
      Uploads and replaces this drive file's contents with the given file and reports transfer progress to the specified TransferProgressCallback.
      Parameters:
      filePath - the updated file contents
      callback - the callback be notified of transfer progress
      Returns:
      a new drive file that represents this updated file
      Throws:
      IOException - if unable to read the file.
      See Also:
    • uploadAsync

      @Deprecated public DriveFileUploadExecution uploadAsync(File file) throws IOException
      Deprecated.
      use uploadAsync(Path) instead
      Uploads and replaces this drive file's contents asynchronously with the given file. Consumers can block on transfer completion by invoking DriveFileUploadExecution.get().
      Parameters:
      file - the updated file contents
      Returns:
      a new drive file that represents this updated file
      Throws:
      IOException - if unable to read the file.
      See Also:
    • uploadAsync

      public DriveFileUploadExecution uploadAsync(Path filePath) throws IOException
      Uploads and replaces this drive file's contents asynchronously with the given file. Consumers can block on transfer completion by invoking DriveFileUploadExecution.get().
      Parameters:
      filePath - the updated file contents
      Returns:
      a new drive file that represents this updated file
      Throws:
      IOException - if unable to read the file.
      See Also:
    • uploadAsync

      @Deprecated public DriveFileUploadExecution uploadAsync(File file, com.amilesend.client.connection.file.TransferProgressCallback callback) throws IOException
      Uploads and replaces this drive file's contents asynchronously with the given file and reports transfer progress to the specified TransferProgressCallback.
      Parameters:
      file - the updated file contents
      callback - the callback be notified of transfer progress
      Returns:
      the async execution used to obtain the drive file once it has completed
      Throws:
      IOException - if unable to read the file.
      See Also:
      • TransferProgressCallback
    • uploadAsync

      public DriveFileUploadExecution uploadAsync(Path filePath, com.amilesend.client.connection.file.TransferProgressCallback callback) throws IOException
      Uploads and replaces this drive file's contents asynchronously with the given file and reports transfer progress to the specified TransferProgressCallback.
      Parameters:
      filePath - the updated file contents
      callback - the callback be notified of transfer progress
      Returns:
      the async execution used to obtain the drive file once it has completed
      Throws:
      IOException - if unable to read the file.
      See Also:
      • TransferProgressCallback
    • update

      public DriveFile update()
      Updates the attributes for this file.
      Returns:
      the updated drive file
    • preview

      public Preview preview(PreviewRequest request)
      Gets the embeddable file preview URLs for inclusion in a web-based UI. Note: For long-lived embeddable links, use DriveItemType.createSharingLink(CreateSharingLinkRequest) instead.
      Parameters:
      request - the preview item request
      Returns:
      the preview URLs
    • move

      public DriveFile move(DriveFolder destinationFolder)
      Moves this file to the specified DriveFolder.
      Parameters:
      destinationFolder - the destination drive folder
      Returns:
      the updated drive file that represents this moved file
    • move

      public DriveFile move(@NonNull DriveFolder destinationFolder, String newName)
      Moves this file to the specified DriveFolder along with the new file name.
      Parameters:
      destinationFolder - the destination drive folder
      newName - the new name of the file
      Returns:
      the updated drive file that represents this moved file
    • move

      public DriveFile move(String destinationParentId, String newName)
      Moves this file to the specified newParentId (i.e., represents a new DriveFolder's ID) along with the new file name.
      Parameters:
      destinationParentId - the new parent destination ID
      newName - the new name of the file
      Returns:
      the updated drive file that represents this moved file.