Uploading

HTTP Upload workflow

The upload process has two steps:

  • you retrieve an upload URL using the file object of the API
  • you POST your file to this upload URL

Get the upload URL

Request:

{
  "call": "file.upload",
  "args": {},
  "auth": "4c1a4d3edede832bfd000002:a8fe012836ddd0df62e6403d254b4ae6",
}

Response:

{
  "result": {
    "url": "http://upload-02.dmcloud.net/upload?uuid=ab91fc66c72a11dfa06f0026b9f94f64&seal=7074b95b20cd5aab0b723e660e419651"
  }
}

Post the Video file

In this step you will do a multipart POST on the URL returned in the previous step with the file argument for the binary file data.

Response:

{
  'url': 'http://upload-02.dmcloud.net/files/1131afc3faee587a6d85e392bd7e7638.3gp',
  'seal': u'7dfe04a8cbb849b1ae0bf855e4f4ee17',
  'hash': u'a5074ec35069294cdd74938fb9e20f88f3a744c2',
  'name': 'video',
  'size': 92543
}

The response contains a URL that you can use as a parameter for the create method of the media object.

Example request:

{
  "call": "media.create",
  "args": {
    "url": "http://upload-02.dmcloud.net/files/1131afc3faee587a6d85e392bd7e7638.3gp",
    "assets_names": [
      "flv_h263_mp3",
      "mp4_h264_aac"
    ]
  },
  "auth": "4c1a4d3edede832bfd000002:25d56cdc1185b0a054f89a17263c1da6",
}

Example response:

{
  "result": {
    "id": "4c9b6917dede8351d600000a"
  }
}

FTP Upload workflow

You must connect to ftp.dmcloud.net using the FTP protocol. You can either use your login/password or user_id/api_key as credentials.

There are two ways to upload your media, use the advanced method if you need one of these features:

  • setting the metadata (e.g.: title)
  • getting the media_id of the uploaded file
  • checking the md5 checksum of the uploaded file
  • having more than 1 minute to resume an upload

Otherwise you can use the simple method.

Simple Upload

You only have to upload your files, they will be processed approximatively 1 minute after the upload. You have 1 minute to resume the upload in case of interruption. The source file will be automatically deleted when processed.

Advanced Upload

The advanced method allows to provide one special file along each media file.

This file must be uploaded either:

  • before the media file
  • during the media file upload
  • up to 1 minute after the upload of the media file

The allowed file formats are:

  • JSON (http://en.wikipedia.org/wiki/Json)
  • INI (http://en.wikipedia.org/wiki/INI_file)

This file must be named exactly like the media file plus the json or ini extension after the extension of the media file. Example: for a media file named my_video.mp4, the special file will be named my_video.mp4.ini or my_video.mp4.json depending on the file format.

Warning: do not replace the media file extension by ‘.ini’ or ‘.json’ but append ‘.ini’ or ‘.json’ to it.

Format of the metadata file:

  • Section [file]
    • md5sum (optional): the md5 checksum of the media file, if present the media won’t be processed until the checksum match. This give you a delay to resume the media upload.
    • media_id: if the value is ‘1’ then a file with the ‘.result’ extension and the same name as the uploaded file will be created when the media is processed, this file will contain the media_id of the corresponding media.
  • Section [meta]
    • a list of key/value that will be added to the media metadata (eg: title=my title)

Examples:

For a video file named cute_cat.mp4, the INI file will be cute_cat.mp4.ini:

[file]
md5sum=6dbd838cda2a9d54228210d214219d28
media_id=1
[meta]
title=My awesome cat
description=This is my cat doing amazing things
channel=animals
tags=cat,funny,cool,amazing

For a video file named cute_cat.mp4, the JSON file will be cute_cat.mp4.json:

{
    "file" : {
        "md5sum" : "6dbd838cda2a9d54228210d214219d28",
        "media_id" : "1"
    },
    "meta" : {
        "title" : "My awesome cat",
        "description" : "This is my cat doing amazing things",
        "channel" : "animals",
        "tags" : "cat,funny,cool,amazing"
    }
}

Table Of Contents