OneDrive API allows easy interaction with the files APIs of Microsoft Graph. It follows the OneDrive API module for Node.js.
This library is exclusively for the files APIs. For other Microsoft APIs, check out microsoft_graph_api.
Note: Using this library requires an access token.
- Create Folders
- Delete Files and Folders
- Create Shareable Links
- Download Files and Folders
- Fetch Metadata
- List Files and Folders
- Retrieve File Preview URLs
- Retrieve File Thumbnails
- Update Metadata
- Upload Files
import 'package:onedrive_api/onedrive_api.dart';
void main() async {
FolderParams folderParams = FolderParams();
folderParams.accessToken = "ACCESS_TOKEN";
folderParams.name = "Test Folder";
Response response = await createFolder(folderParams);
if (response.statusCode != 201) {
throw Exception(response.errorMsg);
} else {
print("Item Created: ${response.itemId}");
}
}
import 'package:onedrive_api/onedrive_api.dart';
void main() async {
ItemParams itemParams = ItemParams();
itemParams.accessToken = "ACCESS_TOKEN";
itemParams.itemId = "ITEM_ID";
Response response = await delete(itemParams);
if (response.statusCode != 204) {
throw Exception(response.errorMsg);
} else {
print("Item Deleted: ${itemParams.itemId}");
}
}