Lua
Lua
Frame.io - Create a Folder
See more Frame.io Examples
Create a folder asset as a child to the root_asset_id.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- 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"
-- }
local json = chilkat.JsonObject.new()
json:update_string("type", "folder")
json:update_string("name", "Folder at root")
http:set_request_header("content-type", "application/json")
-- Adds the "Authorization: Bearer <FRAME_IO_DEV_TOKEN>" header.
http.auth_token = "<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.
local resp = chilkat.HttpResponse.new()
local success = http:http_json("POST", "https://api.frame.io/v2/assets/4ecb383f-71a8-4233-b665-d8f75136f554/children", json, "application/json", resp)
if not success then
print(http.last_error_text)
return
end
local sbResponseBody = chilkat.StringBuilder.new()
resp:get_body_sb(sbResponseBody)
local jResp = chilkat.JsonObject.new()
jResp:load_sb(sbResponseBody)
jResp.emit_compact = false
print("Response Body:")
print(jResp:emit())
local respStatusCode = resp.status_code
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
print("Response Header:")
print(resp.header)
print("Failed.")
return
end
-- 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
local team_id = jResp:string_of("team_id")
local public_item_count = jResp:int_of("public_item_count")
local properties = jResp:string_of("properties")
local deleted_at = jResp:string_of("deleted_at")
local fps = jResp:string_of("fps")
local rating = jResp:string_of("rating")
local description = jResp:string_of("description")
local updated_at = jResp:string_of("updated_at")
local cover_asset_id = jResp:string_of("cover_asset_id")
local archive_scheduled_at = jResp:string_of("archive_scheduled_at")
local subtitle_tracks = jResp:string_of("subtitle_tracks")
local index = jResp:string_of("index")
local item_count = jResp:int_of("item_count")
local account_id = jResp:string_of("account_id")
local name = jResp:string_of("name")
local checksums = jResp:string_of("checksums")
local audio_tracks = jResp:string_of("audio_tracks")
local duration = jResp:string_of("duration")
local label = jResp:string_of("label")
local is_session_watermarked = jResp:bool_of("is_session_watermarked")
local parent_id = jResp:string_of("parent_id")
local versions = jResp:int_of("versions")
local project_id = jResp:string_of("project_id")
local resource_id = jResp:string_of("resource_id")
local v_private = jResp:bool_of("private")
local frames = jResp:int_of("frames")
local autoversion_id = jResp:string_of("autoversion_id")
local v_type = jResp:string_of("type")
local uploaded_at = jResp:string_of("uploaded_at")
local creator_id = jResp:string_of("creator_id")
local user_permissionsCan_download = jResp:bool_of("user_permissions.can_download")
local user_permissionsCan_modify_template = jResp:bool_of("user_permissions.can_modify_template")
local user_permissionsCan_public_share_presentation = jResp:bool_of("user_permissions.can_public_share_presentation")
local user_permissionsCan_public_share_review_link = jResp:bool_of("user_permissions.can_public_share_review_link")
local user_permissionsCan_share_downloadable_presentation = jResp:bool_of("user_permissions.can_share_downloadable_presentation")
local user_permissionsCan_share_downloadable_review_link = jResp:bool_of("user_permissions.can_share_downloadable_review_link")
local user_permissionsCan_share_unwatermarked_presentation = jResp:bool_of("user_permissions.can_share_unwatermarked_presentation")
local user_permissionsCan_share_unwatermarked_review_link = jResp:bool_of("user_permissions.can_share_unwatermarked_review_link")
local shared = jResp:bool_of("shared")
local is_360 = jResp:bool_of("is_360")
v_type = jResp:string_of("_type")
local comment_count = jResp:int_of("comment_count")
local archived_at = jResp:string_of("archived_at")
local filetype = jResp:string_of("filetype")
local id = jResp:string_of("id")
local hard_deleted_at = jResp:string_of("hard_deleted_at")
local copy = jResp:bool_of("copy")
local is_hls_required = jResp:bool_of("is_hls_required")
local archive_status = jResp:string_of("archive_status")
local inserted_at = jResp:string_of("inserted_at")
local filesize = jResp:int_of("filesize")