{"__v":2,"_id":"54bd6b1fc264d50c00d9ef8e","category":{"__v":17,"_id":"543435b1edce040800409240","pages":["5434906a5b10711400c6c45b","543492315b10711400c6c474","5480a347a3e4ea22000976c4","5480a36ea3e4ea22000976c5","5480a568e952bb1a006b31fb","54ae8b0686f2690b0072b76f","54aeac7b86f2690b0072b7ac","54aeae133697fc1600d894e3","54aed028194a5f1f00a1d172","54aed212194a5f1f00a1d176","54aedfb4194a5f1f00a1d199","54aee0eb194a5f1f00a1d19e","54aee1aa194a5f1f00a1d1a3","54bd5f54c264d50c00d9ef7e","54bd5f5aa0d4080c005f5449","54bd6b1fc264d50c00d9ef8e","559a9069155eef1700f4e68a"],"project":"54343170fa5527080064f449","version":"54343531bfaa3d0800c4d4af","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-07T18:49:21.998Z","from_sync":false,"order":2,"slug":"assets","title":"Assets"},"editedParams":true,"editedParams2":true,"parentDoc":null,"project":"54343170fa5527080064f449","user":"54343147fa5527080064f43f","version":{"__v":27,"_id":"54343531bfaa3d0800c4d4af","forked_from":"54343170fa5527080064f44c","project":"54343170fa5527080064f449","createdAt":"2014-10-07T18:47:13.086Z","releaseDate":"2014-10-07T18:47:13.086Z","categories":["54343531bfaa3d0800c4d4b0","543435b1edce040800409240","543435b9edce040800409241","543435bcedce040800409243","543435bfedce040800409244","543435c2edce040800409245","54370cc426469424002a6dfa","54370cf026469424002a6dfd","5437129d26469424002a6e2f","543712d226469424002a6e30","5480c8fd74904f1a00053c86","54aafc6eefb39016009e4d71","54ac1d36de18cc1400226e01","54ad59369219922100751732","54b41bcf4f25cb1600518d2c","54b533a3a806f40c0050d53c","54b54bbf96fe3c0b00d38d2a","54b688a27379a90c00f53a8a","54b699efbc1a46160005edfa","54b8191691011f0b00068804","54bfb002d03bfc0d0000e814","54bfb33ed03bfc0d0000e816","55a3e94e912a6e2300882cdb","55a56c370f354f0d00fd02a8","55e85ad034516037002e9325","5638ecb62fc5520d001a4cf9","572cba2fc310640e008f63d5"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.0.0","version":"3.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-01-19T20:37:51.463Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[]},"results":{"codes":[{"name":"","code":"{\n    \"assetUrl\": \"https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-ffff-bbbb-b9af-1999d2c7835b/MyVideo.mov\",\n    \"amzDate\": \"Mon, 19 Jan 2015 19:17:33 GMT\",\n    \"amzAcl\": \"private\",\n    \"contentType\": \"video/quicktime\",\n    \"authorization\": \"AWS AKIAIFFFICBLRC7JU6RA:bF4dV+HkF30vCct4V1/uRKjPDFo=\",\n    \"httpMethod\": \"PUT\"\n}","language":"json","status":200}]},"settings":"","auth":"required","params":[{"_id":"54bd6b1fc264d50c00d9ef91","ref":"","in":"body","required":true,"desc":"Name of the file to be stored.","default":"","type":"string","name":"fileName"}],"url":"/assets/upload"},"isReference":false,"order":11,"body":"Requesting an upload ticket returns all information necessary to perform a file upload (POST, PUT) directly to MediaSilo. This is especially useful for building applications that synchronize directories to MediaSilo or bridge a local asset management system with MediaSilo in the cloud. The returned data allows you to perform a normal PUT with a file object.\n\nFiles uploaded using this process are limited to 5 GB per file or less.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Attribute\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"fileName\",\n    \"0-1\": \"This is the file name as it will be stored in S3. It does not have to be the actual name of the local file.\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Step 1: Create the Upload Ticket\"\n}\n[/block]\nLet's assume we sent the following request to obtain an upload ticket:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /v3/assets/upload\\n{\\n    \\\"fileName\\\": \\\"myfile.mov\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nAnd we receive the following payload in response:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// 200 OK\\n{\\n    \\\"assetUrl\\\": \\\"https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-ffff-bbbb-b9af-1999d2c7835b/myfile.mov\\\",\\n    \\\"amzDate\\\": \\\"Mon, 19 Jan 2015 19:17:33 GMT\\\",\\n    \\\"amzAcl\\\": \\\"private\\\",\\n    \\\"contentType\\\": \\\"video/quicktime\\\",\\n    \\\"authorization\\\": \\\"AWS AKIAIFFFICBLRC7JU6RA:bF4dV+HkF30vCct4V1/uRKjPDFo=\\\",\\n    \\\"httpMethod\\\": \\\"PUT\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Attribute\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"assetUrl\",\n    \"0-1\": \"This is the URL to be used in your subsequent POST. It must remain unchanged.\",\n    \"1-0\": \"amzDate\",\n    \"1-1\": \"The date of the request. Must remain unchanged.\",\n    \"2-0\": \"amzAcl\",\n    \"2-1\": \"Always private. Files uploaded this way are not publicly accessible. Requesting the file after upload will result in a 403 error. Only MediaSilo servers can access the uploaded file.\",\n    \"3-0\": \"contentType\",\n    \"3-1\": \"The file's content mime type which was automatically determined.\",\n    \"4-0\": \"authorization\",\n    \"4-1\": \"This is is a one time, time limited signature that acts as an authentication string. Must remain unchanged.\",\n    \"5-0\": \"httpMethod\",\n    \"5-1\": \"The suggested method for file upload.\"\n  },\n  \"cols\": 2,\n  \"rows\": 6\n}\n[/block]\nThis response contains all we need to start the upload process.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Step 2: Upload file\"\n}\n[/block]\nFile upload can be done in a browser (via JavaScript) or using any number of server side languages (Java, PHP, Python, Node, etc.). See the following examples in JavaScript and CURL (command line).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X PUT \\\"**assetUrl**\\\" -H \\\"Authorization: **authorization**\\\" -H \\\"x-amz-acl: **amzAcl**\\\" -H \\\"Content-Type: **contentType**\\\" -H \\\"x-amz-date: **amzDate**\\\" -T **path/to/local/file**\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"function uploadFile(fileObject) {\\n\\txhr = new XMLHttpRequest();\\n  xhr.open('PUT', 'https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-ffff-bbbb-b9af-1999d2c7835b/myfile.mov', true);\\n  xhr.setRequestHeader('x-amz-date', 'Mon, 19 Jan 2015 19:17:33 GMT');\\n  xhr.setRequestHeader('Authorization', 'AWS AKIAIFFFICBLRC7JU6RA:bF4dV+HkF30vCct4V1/uRKjPDFo=');\\n  xhr.setRequestHeader('x-amz-acl', 'private');\\n  xhr.setRequestHeader('Content-Type', 'video/quicktime');\\n  xhr.send(fileObject);\\n}\",\n      \"language\": \"javascript\"\n    },\n    {\n      \"code\": \"curl -X PUT \\\"https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-ffff-bbbb-b9af-1999d2c7835b/MyVideo.mov\\\" -H \\\"Authorization: AWS AKIAIFFFICBLRC7JU6RA:bF4dV+HkF30vCct4V1/uRKjPDFo=\\\" -H \\\"x-amz-acl:private\\\" -H \\\"Content-Type: video/quicktime\\\" -H \\\"x-amz-date: Mon, 19 Jan 2015 19:17:33 GMT\\\" -T videos/MyVideo.mov\",\n      \"language\": \"json\",\n      \"name\": \"CURL\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Data Fields\",\n  \"body\": \"All data needs to be passed along exactly as it was returned in the ticket request.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Create Asset\"\n}\n[/block]\nOnce the file uploaded successfully, [create the asset](http://docs.mediasilo.com/v3.0/docs/create-asset) using the API as usual.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /v3/assets\\n{\\n    \\\"sourceUrl\\\": \\\"https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-282f-4aa2-b9af-1999d2c7835b/myfile.mov\\\",\\n    \\\"projectId\\\": \\\"0XXXCC-014B-2XX0-CF518DXXXX393E\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","excerpt":"Request a file upload ticket to upload directly to MediaSilo","slug":"create-upload-ticket","type":"post","title":"File Upload"}

postFile Upload

Request a file upload ticket to upload directly to MediaSilo

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

fileName:
required
string
Name of the file to be stored.

Result Format


Documentation

Requesting an upload ticket returns all information necessary to perform a file upload (POST, PUT) directly to MediaSilo. This is especially useful for building applications that synchronize directories to MediaSilo or bridge a local asset management system with MediaSilo in the cloud. The returned data allows you to perform a normal PUT with a file object. Files uploaded using this process are limited to 5 GB per file or less. [block:parameters] { "data": { "h-0": "Attribute", "h-1": "Description", "0-0": "fileName", "0-1": "This is the file name as it will be stored in S3. It does not have to be the actual name of the local file." }, "cols": 2, "rows": 1 } [/block] [block:api-header] { "type": "basic", "title": "Step 1: Create the Upload Ticket" } [/block] Let's assume we sent the following request to obtain an upload ticket: [block:code] { "codes": [ { "code": "POST /v3/assets/upload\n{\n \"fileName\": \"myfile.mov\"\n}", "language": "json" } ] } [/block] And we receive the following payload in response: [block:code] { "codes": [ { "code": "// 200 OK\n{\n \"assetUrl\": \"https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-ffff-bbbb-b9af-1999d2c7835b/myfile.mov\",\n \"amzDate\": \"Mon, 19 Jan 2015 19:17:33 GMT\",\n \"amzAcl\": \"private\",\n \"contentType\": \"video/quicktime\",\n \"authorization\": \"AWS AKIAIFFFICBLRC7JU6RA:bF4dV+HkF30vCct4V1/uRKjPDFo=\",\n \"httpMethod\": \"PUT\"\n}", "language": "json" } ] } [/block] [block:parameters] { "data": { "h-0": "Attribute", "h-1": "Description", "0-0": "assetUrl", "0-1": "This is the URL to be used in your subsequent POST. It must remain unchanged.", "1-0": "amzDate", "1-1": "The date of the request. Must remain unchanged.", "2-0": "amzAcl", "2-1": "Always private. Files uploaded this way are not publicly accessible. Requesting the file after upload will result in a 403 error. Only MediaSilo servers can access the uploaded file.", "3-0": "contentType", "3-1": "The file's content mime type which was automatically determined.", "4-0": "authorization", "4-1": "This is is a one time, time limited signature that acts as an authentication string. Must remain unchanged.", "5-0": "httpMethod", "5-1": "The suggested method for file upload." }, "cols": 2, "rows": 6 } [/block] This response contains all we need to start the upload process. [block:api-header] { "type": "basic", "title": "Step 2: Upload file" } [/block] File upload can be done in a browser (via JavaScript) or using any number of server side languages (Java, PHP, Python, Node, etc.). See the following examples in JavaScript and CURL (command line). [block:code] { "codes": [ { "code": "curl -X PUT \"**assetUrl**\" -H \"Authorization: **authorization**\" -H \"x-amz-acl: **amzAcl**\" -H \"Content-Type: **contentType**\" -H \"x-amz-date: **amzDate**\" -T **path/to/local/file**", "language": "text" } ] } [/block] [block:code] { "codes": [ { "code": "function uploadFile(fileObject) {\n\txhr = new XMLHttpRequest();\n xhr.open('PUT', 'https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-ffff-bbbb-b9af-1999d2c7835b/myfile.mov', true);\n xhr.setRequestHeader('x-amz-date', 'Mon, 19 Jan 2015 19:17:33 GMT');\n xhr.setRequestHeader('Authorization', 'AWS AKIAIFFFICBLRC7JU6RA:bF4dV+HkF30vCct4V1/uRKjPDFo=');\n xhr.setRequestHeader('x-amz-acl', 'private');\n xhr.setRequestHeader('Content-Type', 'video/quicktime');\n xhr.send(fileObject);\n}", "language": "javascript" }, { "code": "curl -X PUT \"https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-ffff-bbbb-b9af-1999d2c7835b/MyVideo.mov\" -H \"Authorization: AWS AKIAIFFFICBLRC7JU6RA:bF4dV+HkF30vCct4V1/uRKjPDFo=\" -H \"x-amz-acl:private\" -H \"Content-Type: video/quicktime\" -H \"x-amz-date: Mon, 19 Jan 2015 19:17:33 GMT\" -T videos/MyVideo.mov", "language": "json", "name": "CURL" } ] } [/block] [block:callout] { "type": "info", "title": "Data Fields", "body": "All data needs to be passed along exactly as it was returned in the ticket request." } [/block] [block:api-header] { "type": "basic", "title": "3. Create Asset" } [/block] Once the file uploaded successfully, [create the asset](http://docs.mediasilo.com/v3.0/docs/create-asset) using the API as usual. [block:code] { "codes": [ { "code": "POST /v3/assets\n{\n \"sourceUrl\": \"https://s3.amazonaws.com/ingest-east.mediasilo.com/26a35865-282f-4aa2-b9af-1999d2c7835b/myfile.mov\",\n \"projectId\": \"0XXXCC-014B-2XX0-CF518DXXXX393E\"\n}", "language": "json" } ] } [/block]

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}