Class DriveItem

java.lang.Object
com.amilesend.onedrive.resource.item.BaseItem
com.amilesend.onedrive.resource.item.DriveItem
Direct Known Subclasses:
SpecialDriveItem

public class DriveItem extends BaseItem
Describes a resource stored in a drive.

API Documentation.

  • Field Details

  • Method Details

    • download

      public void download(@NonNull Path folderPath, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback)
      Downloads the drive item and reports transfer progress to the given TransferProgressCallback.

      API Documentation.

      Parameters:
      folderPath - the path of the folder to download the drive item content to
      callback - the callback to inform of transfer progress
    • downloadAsync

      public CompletableFuture<Long> downloadAsync(@NonNull Path folderPath, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback)
      Downloads the drive item asynchronously that reports transfer progress and completion to the specified TransferProgressCallback.

      API Documentation.

      Parameters:
      folderPath - the path of the folder to download the drive item content to
      callback - the callback to inform of transfer progress
      Returns:
      the CompletableFuture used to fetch the number of bytes downloaded
    • upload

      public DriveItem upload(@NonNull Path filePath, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) throws IOException
      Uploads a file to replace the contents of this DriveItem and reports the transfer status to the given TransferProgressCallback.

      API Documentation.

      Parameters:
      filePath - the file to upload
      callback - the callback to inform of transfer progress
      Returns:
      the updated drive item information
      Throws:
      IOException - if unable to read or determine the file's content type
    • uploadAsync

      public CompletableFuture<DriveItem> uploadAsync(@NonNull Path filePath, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) throws IOException
      Uploads a file asynchronously to replace the contents of this DriveItem and reports the transfer status to the given TransferProgressCallback.

      API Documentation.

      Parameters:
      filePath - the file to upload
      callback - the callback to inform of transfer progress
      Returns:
      the CompletableFuture to fetch the updated drive item information
      Throws:
      IOException - if unable to read or determine the file's content type
    • uploadNew

      public DriveItem uploadNew(@NonNull Path filePath, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) throws IOException
      Uploads a new file as a child of this DriveItem and reports the transfer status to the given TransferProgressCallback.

      API Documentation.

      Parameters:
      filePath - the file to upload
      callback - the callback to inform of transfer progress
      Returns:
      the new child drive item associated with the uploaded file
      Throws:
      IOException - if unable to read or determine the file's content type
    • uploadNewAsync

      public CompletableFuture<DriveItem> uploadNewAsync(@NonNull Path filePath, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) throws IOException
      Uploads a new file asynchronously as a child of this DriveItem and reports the transfer status to the given TransferProgressCallback.

      API Documentation.

      Parameters:
      filePath - the file to upload
      callback - the callback to inform of transfer progress
      Returns:
      the completable future to fetch the updated drive item information
      Throws:
      IOException - if unable to read or determine the file's content type
    • create

      public DriveItem create(@NonNull DriveItem newChildDriveItem)
      Creates a new DriveItem as a child of this.

      API Documentation.

      Parameters:
      newChildDriveItem - the new drive item to create
      Returns:
      the new drive item
    • update

      public DriveItem update()
      Updates this drive item.

      API Documentation.

      Returns:
      the updated drive item
    • move

      public DriveItem move(String destinationParentId, String newName)
      Moves this DriveItem as a child to the given newParentId, updates the name, or both.

      API Documentation.

      Parameters:
      destinationParentId - the new parent identifier
      newName - the new name
      Returns:
      the updated drive item
    • copy

      public AsyncJob copy(String destinationParentId, String newName)
      Copies this DriveItem to a child of the given destinationParentId and updates the name of the copied DriveItem.
      Parameters:
      destinationParentId - the new destination parent identifier
      newName - the new name
      Returns:
      the AsyncJob that can be used to poll for the remote asynchronous operation progress.
      See Also:
    • delete

      public void delete()
      Deletes this drive item.
    • getActivities

      public List<ItemActivity> getActivities()
      Queries and fetches the activities associated with this DriveItem.

      API Documentation.

      Returns:
      the list of activities
    • getChildren

      public List<DriveItem> getChildren()
      Fetches the list of child DriveItems associated with this DriveItem.

      API Documentation.

      Returns:
      list of child drive items
    • getVersions

      public List<DriveItemVersion> getVersions()
      Fetches the list of versions of this DriveItem.

      API Documentation.

      Returns:
      the list of versions
      See Also:
    • getPermissions

      public List<Permission> getPermissions()
      Fetches the list of permissions associated with this DriveItem.

      API Documentation.

      Returns:
      the list of permissions
      See Also:
    • addPermission

      public List<Permission> addPermission(@NonNull AddPermissionRequest requestBody)
      Adds a permission to this DriveItem for the given request.

      API Documentation.

      Parameters:
      requestBody - the descriptor of the permission to add
      Returns:
      the list of permissions for the associate item.
    • createSharingLink

      public Permission createSharingLink(@NonNull CreateSharingLinkRequest requestBody)
      Creates a sharing link for the given request.

      API Documentation.

      Parameters:
      requestBody - the descriptor of the type of link to share
      Returns:
      the sharing permissions that includes the link
    • previewItem

      public Preview previewItem(@NonNull PreviewRequest requestBody)
      Gets the embeddable file preview URLs for inclusion in a web-based UI. Note: For long-lived embeddable links, use createSharingLink(CreateSharingLinkRequest) instead.

      API Documentation.

      Parameters:
      requestBody - the preview item request body
      Returns:
      the preview URLs
    • getThumbnails

      public List<ThumbnailSet> getThumbnails()
      Fetches the list of thumbnail sets associated with this DriveItem.
      Returns:
      the list of thumbnail sets
      See Also:
    • search

      public List<DriveItem> search(String query)
      Search for items associated with this DriveItem.

      API Documentation.

      Parameters:
      query - the search query
      Returns:
      the list of drive items associated with the query
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class BaseItem
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BaseItem
    • builder

      public static DriveItem.DriveItemBuilder<?,?> builder()
    • getAudio

      public Audio getAudio()
      The audio file attributes (read-only).
    • getCTag

      public String getCTag()
      An eTag for the content of the item (read-only).
    • getFile

      public File getFile()
      Indicates if an item is a file (read-only).
    • getFolder

      public Folder getFolder()
      Describes if a given drive item is a folder resource type (read-only).
    • getImage

      public Image getImage()
      The image attributes for a file (read-only).
    • getLocation

      public GeoCoordinates getLocation()
      The geographic coordinates and elevation of a file (read-only).
    • getMalware

      public Object getMalware()
      If defined, malware was detected in the file (read-only).
    • get_package

      public Package get_package()
      Indicates that a drive item is the top level item in a collection of items (read-only).
    • getPhoto

      public Photo getPhoto()
      The photo attributes for a drive item file (read-only).
    • getPublication

      public PublicationFacet getPublication()
      The published status of a drive item or version (read-only).
    • getRemoteItem

      public RemoteItem getRemoteItem()
      Indicates that a drive item references one that exists in another drive (read-only).
    • getRoot

      public Object getRoot()
      If defined, indicates that the item is the top-most folder in the drive (read-only).
    • getSearchResult

      public SearchResult getSearchResult()
      Indicates that the item is in response to a search query (read-only).
    • getShared

      public Shared getShared()
      Indicates that a drive item has been shared with others (read-only).
    • getSharepointIds

      public SharePointIds getSharepointIds()
      SharePoint resource identifiers for SharePoint and Business account items (read-only).
    • getSize

      public long getSize()
      The size of the item in bytes (read-only).
    • getSpecialFolder

      public SpecialFolder getSpecialFolder()
      Describes if the item is a special managed folder (read-only).
    • getVideo

      public Video getVideo()
      The video file attributes (read-only).
    • getDownloadUrl

      public String getDownloadUrl()
      The URL that can be used to download the file's content (read-only).
    • getConnection

      public OneDriveConnection getConnection()
      Gets the underlying connection instance.
    • getDeleted

      public Deleted getDeleted()
      Indicates if an item was deleted (read-only).
    • getFileSystemInfo

      public FileSystemInfo getFileSystemInfo()
      Describes drive (client-side) properties of the local version of a drive item.
    • getConflictBehavior

      public String getConflictBehavior()
      Describes how to handle conflicts upon copy/move operations. Valid values include:
      • fail
      • replace
      • rename
      This member is write-only.
    • getSourceUrl

      public String getSourceUrl()
      The source URL for remote uploading of file contents (write-only). Currently not tested nor supported.
    • toString

      public String toString()
      Overrides:
      toString in class BaseItem
    • setFileSystemInfo

      public void setFileSystemInfo(FileSystemInfo fileSystemInfo)
      Describes drive (client-side) properties of the local version of a drive item.
    • setConflictBehavior

      public void setConflictBehavior(String conflictBehavior)
      Describes how to handle conflicts upon copy/move operations. Valid values include:
      • fail
      • replace
      • rename
      This member is write-only.
    • setSourceUrl

      public void setSourceUrl(String sourceUrl)
      The source URL for remote uploading of file contents (write-only). Currently not tested nor supported.