Package com.independentsoft.graph.files
Class DriveItem
java.lang.Object
com.independentsoft.graph.files.DriveItem
- All Implemented Interfaces:
ICreatable
Represents a file, folder, or other item stored in a drive in Microsoft Graph.
The DriveItem resource is the main object for working with files and folders in OneDrive, SharePoint document libraries, and Teams. DriveItem represents both files and folders, with folders having a folder facet and files having a file facet.
DriveItem supports:
- File and folder operations (create, read, update, delete)
- File content upload and download
- Metadata management (name, description, tags)
- File sharing and permissions
- File versioning and change tracking
- Search across files and folders
- Thumbnails for images and videos
- Special properties for photos, videos, and documents
Example usage:
GraphClient client = new GraphClient();
// ... configure authentication ...
// Get a drive item by ID
DriveItem item = client.getDriveItem("item-id");
System.out.println("Name: " + item.getName());
System.out.println("Size: " + item.getSize() + " bytes");
// Check if it's a folder
if (item.getFolderProperties() != null) {
System.out.println("This is a folder with " +
item.getFolderProperties().getChildCount() + " children");
}
// Upload a file
DriveItem newFile = new DriveItem();
newFile.setName("document.pdf");
newFile.setContent(fileBytes);
DriveItem uploaded = client.uploadDriveItem("parent-folder-id", newFile);
// Download file content
byte[] content = client.downloadDriveItemContent(uploaded.getId());
- Since:
- 1.0
- See Also:
- driveItem resource type, Get driveItem, Upload or replace driveItem content
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getCTag()getETag()getId()getName()longgetSize()voidsetContent(byte[] content)voidsetDescription(String description)voidsetFolderProperties(FolderProperties folderProperties)voidvoidsetParentReference(ItemReference parentReference)Converts this object to its JSON representation for creation.toString()
-
Constructor Details
-
DriveItem
public DriveItem() -
DriveItem
-
-
Method Details
-
toCreateJson
Description copied from interface:ICreatableConverts this object to its JSON representation for creation.This method generates a JSON string containing all properties needed to create a new instance of this resource in Microsoft Graph. Only properties appropriate for creation should be included (e.g., excluding read-only properties like ID, createdTime, etc.).
- Specified by:
toCreateJsonin interfaceICreatable- Returns:
- JSON string representation for creating this resource
-
toString
-
getId
-
getAudioProperties
-
getContent
public byte[] getContent() -
setContent
public void setContent(byte[] content) -
getCreatedBy
-
getCreatedTime
-
getCTag
-
getDeletedProperties
-
getDescription
-
setDescription
-
getETag
-
getFileProperties
-
getFileSystemInfo
-
getFolderProperties
-
setFolderProperties
-
getImageProperties
-
getLastModifiedBy
-
getLastModifiedTime
-
getLocation
-
getName
-
setName
-
getPackageProperties
-
getParentReference
-
setParentReference
-
getPendingOperations
-
getPhotoProperties
-
getPublicationProperties
-
getRemoteItemProperties
-
getRootProperties
-
getSearchResultProperties
-
getSize
public long getSize() -
getStandardFolder
-
getVideoProperties
-
getWebDavUrl
-
getWebUrl
-