Creates a new DriveItem instance
Initializes a drive item with the provided metadata and optional URI. The drive item represents a file or document within a drive.
Drive item metadata
Optionaluri: stringOptional URI path for the drive item endpoint. Defaults to '/drive/:driveId/item'
Get the access control functionality for this drive item
This getter provides access to the drive item's access control methods through the Access class. It allows for granting and revoking permissions to users, org users, agents, and clients.
An Access instance configured for this drive item
Check if the entity is active
This method checks the active status of the entity. Most entities in the system can be active or inactive, which affects their availability and usability in the platform.
True if the entity is active, false otherwise
Convert model instance to interface data
This method serializes the model instance to a plain object that matches the interface type. This is useful for:
The model data as a plain object matching the interface type
Convert model instance to API payload
This method creates a payload suitable for API requests by:
A clean object suitable for API requests
Update model data with new values
This method updates the model's data and instance properties with new values. It performs a shallow merge of the updates with existing data, allowing for partial updates of the model's properties.
Object containing properties to update
const user = new User({
email: 'old@example.com',
firstName: 'John'
});
// Update multiple properties
user.update({
email: 'new@example.com',
lastName: 'Doe'
});
// Save changes to API
await user.save();
This method only updates the local model instance. To persist changes to the API, call save after updating.
Save the model instance to the API
This method persists the current state of the model to the API using a PUT request. It requires the model to have an ID (existing instance). For new instances, use the collection's create method instead.
The method:
Promise resolving to the updated model data
Delete the model instance from the API
This method permanently deletes the model instance from the API and clears the local data. This operation cannot be undone.
The method:
Promise that resolves when deletion is successful
Get the download URL for this file or folder
Returns a URL that can be used to download the file directly or as a ZIP archive if it's a folder. The download is handled by the backend which either redirects to S3 for files or streams a ZIP archive for folders.
OptionalexpiresIn: numberNumber of seconds until the download URL expires (default: 3600 = 1 hour)
Promise resolving to the download URL
Download a file in the browser:
const item = await drive.items.get({}, itemId);
// Get download URL and trigger download
const url = await item.downloadUrl();
window.location.href = url;
Download with custom expiration:
// Download URL expires in 2 hours
const url = await item.downloadUrl(7200);
// Use with fetch for programmatic download
const response = await fetch(url);
const blob = await response.blob();
DriveItem class for managing files and documents in drives
This class represents a file or document item within a drive in the Mosaia platform. Drive items contain metadata about files, including their location, size, and type.
Features:
Remarks
Drive items represent:
Example
Basic drive item: