Dart
Dart
Frame.io - Create a Folder
See more Frame.io Examples
Create a folder asset as a child to the root_asset_id.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final http = CkHttp();
// Implements the following CURL command:
// curl --request POST \
// --url https://api.frame.io/v2/assets/<root_asset_id>/children \
// --header 'authorization: Bearer <FRAME_IO_DEV_TOKEN>' \
// --header 'content-type: application/json' \
// --data '{"type":"folder", "name": "Folder at root"}'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "type": "folder",
// "name": "Folder at root"
// }
final json = CkJsonObject();
json.updateString('type', 'folder');
json.updateString('name', 'Folder at root');
http.setRequestHeader('content-type', 'application/json');
// Adds the "Authorization: Bearer <FRAME_IO_DEV_TOKEN>" header.
http.authToken = '<FRAME_IO_DEV_TOKEN>';
// Our root_asset_id = 4ecb383f-71a8-4233-b665-d8f75136f554
// You'll need to modify the following line to use your root asset ID.
final resp = CkHttpResponse();
try {
http.httpJson('POST', 'https://api.frame.io/v2/assets/4ecb383f-71a8-4233-b665-d8f75136f554/children', json, 'application/json', resp);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final sbResponseBody = CkStringBuilder();
resp.getBodySb(sbResponseBody);
final jResp = CkJsonObject();
jResp.loadSb(sbResponseBody);
jResp.emitCompact = false;
print('Response Body:');
print(jResp.emit());
final respStatusCode = resp.statusCode;
print('Response Status Code = $respStatusCode');
if (respStatusCode >= 400) {
print('Response Header:');
print(resp.header);
print('Failed.');
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "team_id": "95a5fbad-688d-46fc-aef1-2f011dd76c10",
// "public_item_count": 0,
// "properties": null,
// "deleted_at": null,
// "fps": null,
// "rating": null,
// "description": null,
// "updated_at": "2020-08-18T03:31:59.699011Z",
// "cover_asset_id": null,
// "archive_scheduled_at": null,
// "subtitle_tracks": null,
// "index": -7.0,
// "item_count": 0,
// "account_id": "b1cd046b-a3bf-4ef8-81a6-0afd74ecc455",
// "name": "FolderA",
// "checksums": null,
// "audio_tracks": null,
// "duration": null,
// "label": "none",
// "is_session_watermarked": false,
// "parent_id": "4ecb383f-71a8-4233-b665-d8f75136f554",
// "versions": 0,
// "project_id": "e76653c4-6cc0-4c47-936b-f7885b477dc0",
// "resource_id": null,
// "private": false,
// "frames": 0,
// "autoversion_id": null,
// "type": "folder",
// "uploaded_at": "2020-08-18T03:31:59.697174Z",
// "creator_id": "34b4f98a-7cc9-4159-8f46-c7c3d837fc6f",
// "user_permissions": {
// "can_download": true,
// "can_modify_template": false,
// "can_public_share_presentation": true,
// "can_public_share_review_link": true,
// "can_share_downloadable_presentation": true,
// "can_share_downloadable_review_link": true,
// "can_share_unwatermarked_presentation": true,
// "can_share_unwatermarked_review_link": true
// },
// "shared": false,
// "is_360": false,
// "_type": "folder",
// "comment_count": 0,
// "archived_at": null,
// "filetype": null,
// "id": "039845e8-bffe-4d6b-88d3-c780bae06342",
// "hard_deleted_at": null,
// "copy": false,
// "is_hls_required": false,
// "archive_status": null,
// "inserted_at": "2020-08-18T03:31:59.699011Z",
// "filesize": 0
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
final teamId = jResp.stringOf('team_id');
final publicItemCount = jResp.intOf('public_item_count');
final properties = jResp.stringOf('properties');
final deletedAt = jResp.stringOf('deleted_at');
final fps = jResp.stringOf('fps');
final rating = jResp.stringOf('rating');
final description = jResp.stringOf('description');
final updatedAt = jResp.stringOf('updated_at');
final coverAssetId = jResp.stringOf('cover_asset_id');
final archiveScheduledAt = jResp.stringOf('archive_scheduled_at');
final subtitleTracks = jResp.stringOf('subtitle_tracks');
final index = jResp.stringOf('index');
final itemCount = jResp.intOf('item_count');
final accountId = jResp.stringOf('account_id');
final name = jResp.stringOf('name');
final checksums = jResp.stringOf('checksums');
final audioTracks = jResp.stringOf('audio_tracks');
final duration = jResp.stringOf('duration');
final label = jResp.stringOf('label');
final parentId = jResp.stringOf('parent_id');
final versions = jResp.intOf('versions');
final projectId = jResp.stringOf('project_id');
final resourceId = jResp.stringOf('resource_id');
final frames = jResp.intOf('frames');
final autoversionId = jResp.stringOf('autoversion_id');
var vType = jResp.stringOf('type');
final uploadedAt = jResp.stringOf('uploaded_at');
final creatorId = jResp.stringOf('creator_id');
vType = jResp.stringOf('_type');
final commentCount = jResp.intOf('comment_count');
final archivedAt = jResp.stringOf('archived_at');
final filetype = jResp.stringOf('filetype');
final id = jResp.stringOf('id');
final hardDeletedAt = jResp.stringOf('hard_deleted_at');
final archiveStatus = jResp.stringOf('archive_status');
final insertedAt = jResp.stringOf('inserted_at');
final filesize = jResp.intOf('filesize');
}