Upload1.0

Uploading Concepts


All MediaFire Upload APIs conform to the Multipart MIME standard. As such, the file name is specified in the filename field of the Content-Disposition header. An example for such a header can be found below:

Request
POST http://www.mediafire.com/api/unversioned/upload/simple.php?uploadkey=5bb66g94blnnk&session_token=aa22f5a968f827daf69fd6b3515110c43e036bc5d2ed8b81657dd1bdfe4b4c3e3ea6757d1f47bc3d6a001a16bc6f25abb486c5e779328a5769bd9ed6064edb69 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
X-Filehash:564dc5e9541a494e966066da8b2392e2e70e2438e4fcf4b0058cd9249abc4e1d
X-Filesize:29278
X-Filetype:text/plain
Content-Type: multipart/form-data; boundary=---------------------------41184676334
Content-Length: 29278

-----------------------------41184676334


Summer vacation
-----------------------------41184676334
Content-Disposition: form-data; name="image1"; filename="GrandCanyon.jpg"
Content-Type: image/jpeg

(Binary data not shown)
-----------------------------41184676334--
                        


In the example above, the custom headers X-Filesize and X-Filehash are supplied. While these headers are not required for all upload scenarios, their inclusion is strongly recommended as it will ensure a higher level of upload data integrity. Although it is not shown in this example, the custom header X-Filename is also supported. This will override the filename specified in the Content-Disposition header when Content-Type is application/octet-stream.


Upload Scenarios


Uploading a Small File
Any size file can be uploaded either as a single unit or as a "resumable" upload, likely split into chunks. Resumable uploading is highly recommended for larger files, especially when connectivity problems are expected (as with mobile devices). However, since the smallest possible chunk size is 4 MB, resumable uploads offer no real benefit for files under that size. Follow the instructions in this section to upload a file as a single unbroken unit, a "simple" upload.

  • Pass filename to upload/check to look for naming conflicts. A destination path will also need to be specified via folder_key or filedrop_key for the base, as well as an optional relative path including any subfolders that may need to be created.
  • If storage_limit_exceeded is returned as "yes", then the upload cannot be completed because the user lacks sufficient storage space.
  • If file_exists is returned as "yes", then there is a naming conflict that must be settled, probably by passing a user-specified value of action_on_duplicate to upload/simple.
  • Call upload/simple. An upload key should be returned under doupload.
  • Pass the upload key to upload/poll_upload every few seconds until it returns the quickkey of your newly uploaded file.

Uploading a Large File

The basic premise of a resumable upload is that a large file is broken up into several uniform chunks. Each of these units is essentially treated as a separate file for the purpose of uploading. When all of the units have been uploaded successfully, they are reassembled on the server side. If the upload is interrupted at some point, only the chunk(s) in the process of uploading at that moment will need to be restarted.

  • Pass filename to upload/check to look for naming conflicts. A destination path will also need to be specified via folder_key or filedrop_key for the base, as well as an optional relative path including any subfolders that may need to be created.
  • If storage_limit_exceeded is returned as "yes", then the upload cannot be completed because the user lacks sufficient storage space.
  • If file_exists is returned as "yes", then there is a naming conflict that must be settled, probably by passing a user-specified value of action_on_duplicate to upload/resumable.
  • Use the data returned under resumable_upload to split your file up into number_of_units chunks of unit_size bytes each.
  • For each chunk, call upload/resumable with appropriate header data. An upload key should be returned under doupload.
  • Pass the file's SHA-256 hash and size in bytes with resumable="yes" to ensure that all_units_ready is returned as "yes".
  • If all_units_ready is returned as "no", analyze bitmap to determine which units failed to upload. Repeat the last two steps until all_units_ready is returned as "yes".
  • Pass the upload key to upload/poll_upload every few seconds until it returns the quickkey of your newly uploaded file.


Resuming an Upload

If connectivity is lost during an upload, it can be resumed by following these steps:
  • Pass the filename and path information to upload/check with resumable="yes". all_units_ready should be returned as "no".
  • If necessary, use the data returned under resumable_upload to split your file up into number_of_units chunks of unit_size bytes each.
  • Analyze bitmap to determine which units still need to be uploaded. This field is an array of 16-bit values. each value represents 16 chunks. Each bit indicates whether a unit is uploaded or not. For example, a value of 19, which is 10011 in binary, indicates that units 0, 1, and 4 are uploaded.
  • For each chunk, call upload/resumable with appropriate header data. An upload key should be returned under doupload.
  • Pass the file's SHA-256 hash and size in bytes to upload/check with resumable="yes" to ensure that all_units_ready is returned as "yes".
  • If all_units_ready is returned as "no", analyze bitmap to determine which units failed to upload. Repeat the last two steps until all_units_ready is returned as "yes".
  • Pass the upload key to upload/poll_upload every few seconds until it returns the quickkey of your newly uploaded file.


Decoding the Bitmap

Below is a JavaScript function that can be used to decode the bitmap returned by upload/check API :
/**
* Decodes the bitmap returned by the upload/pre_upload api call (response.resumable_upload.bitmap) * Returns an array of units, the index being the unit's id and the value being a boolean indicating * whether the unit is uploaded or not */ function decodeBitmap(bitmap) {     var uploadUnits = [];     for (var i = 0; i < bitmap.count; i++) {         var word = parseInt(bitmap.words[i], 10);         var bin = word.toString(2);         while(bin.length < 16) {             bin = '0' + bin;         }         for (var b = 0; b < bin.length; b++) {             uploadUnits[i*16 + b] = (bin[15 - b] == '1');         }     }<     return uploadUnits; } // Let's assume the API returned a JSON response which contains a bitmap under (response.resumable_upload.bitmap) having 2 words with values 17 and 32. bitmap = {count: 2, words: [17, 32]}; var unitUploaded = decodeBitmap(bitmap); alert(unitUploaded[0]); // true alert(unitUploaded[3]); // false alert(unitUploaded[4]); // true alert(unitUploaded[21]); // true alert(unitUploaded[22]); // false

"Instant" Uploads
Before choosing between performing a simple upload or a resumable upload, a third possibility should be explored, which is highly preferable, but not always possible. If a file has been uploaded before, by any user, then it already exists in the cloud and there is no need to repeat the upload in full. In order to check the file to be uploaded against all the files in the cloud, a hash of the file must be computed client-side and sent along with the exact file size. This may be a time-consuming process for very large files, but the benefit of performing an instant upload is also proportionally greater.

  • On the initial call to upload/check, include a SHA-256 hash of the file and its size in bytes.
  • If hash_exists is returned as "yes", then call upload/instant.

Legacy MD5 hash
After calling upload/poll_upload API, you will receive the file data information including the hash. Although MD5 hash is deprecated, you may still get MD5 hash for certain files that already exist in our system. For these files, it is not possible to perform future instant uploads at this time. The reason for this discrepancy is the upload/instant API only accepts SHA256 hashes.

Updating an Existing File
If your upload is meant to overwrite a file that already exists in the cloud, you'll be referencing the file by quickkey instead of name and location. The technique varies depending on whether simple or resumable uploading is used.
For Simple Uploads:
  • Pass the file's SHA-256 hash and size in bytes to upload/check.
  • If hash_exists is returned as "yes", then pass the file's hash and size to upload/instant.
  • Otherwise, pass the file's quickkey to upload/update. An upload key should be returned under doupload.
  • Pass the upload key to upload/poll_upload every few seconds until it returns a result of '0' (success).

For resumable uploads:
  • Pass the file's SHA-256 hash and size in bytes to upload/check with resumable="yes".
  • If hash_exists is returned as "yes", then pass the file's hash and size to upload/instant.
  • Otherwise, use the data returned under resumable_upload to split your file up into number_of_units chunks of unit_size bytes each.
  • For each chunk, call upload/resumable with appropriate header data. An upload key should be returned under doupload.
  • Pass the file's SHA-256 hash and size in bytes to upload/check with resumable="yes" to ensure that all_units_ready is returned as "yes".
  • If all_units_ready is returned as "no", analyze bitmap to determine which units failed to upload. Repeat the last two steps until all_units_ready is returned as "yes".
  • Pass the upload key to upload/poll_upload every few seconds until it returns a result of '0' (success).

Applying a Patch to a File
If you have a delta file "diff" patch to apply to a file in the cloud, you'll need to hash the original file before the patch, the patch itself, and the complete file after the patch.
  • Pass the file's quickkey to upload/patch, along with the original file's hash ('source_hash'), the patched file's hash ('target_hash'), and the patched file's size in bytes ('target_size'). An upload key should be returned under doupload.
  • Pass the upload key to upload/poll_upload every few seconds until it returns a result of '0' (success).

For resumable uploads:
  • Pass the complete file's SHA-256 hash and size in bytes to upload/check.
  • If hash_exists is returned as "yes", then pass the file's hash and sizeto upload/instant.
  • Otherwise, pass the patch file's SHA-256 hash and size in bytes to upload/check.
  • Use the data returned under resumable_upload to split your patch file up into number_of_units chunks of unit_size bytes each.
  • For each chunk, call upload/resumable with appropriate header data, along with the original file's hash ('source_hash'), the patched file's hash ('target_hash'), and the patched file's size in bytes ('target_size'). An upload key should be returned under doupload.
  • Pass the patch file's SHA-256 hash and size in bytes to upload/check with resumable="yes" to ensure that all_units_ready is returned as "yes".
  • If all_units_ready is returned as "no", analyze bitmap to determine which units failed to upload. Repeat the last two steps until all_units_ready is returned as "yes".
  • Pass the upload key to upload/poll_upload every few seconds until it returns a result of '0' (success).

Patch uploads allow the client to upload a delta file (patch) to update the content of an existing file instead of uploading the entire file. To update a file with a patch, four additional GET arguments need to be passed:
  • quickkey : The quickkey of the file being patched/updated.
  • source_hash : The hash of the file being patched/updated.
  • target_hash : A SHA-256 check-sum of the target file.
  • target_size : The size of the target file.

The patch file should be created on the client-side using the same algorithm used by xdelta 3. Please check http://xdelta.org/ for more details.


Add Web Upload


Description : Adds a new web upload and returns the Upload Key on success.

Required Parameters

  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature).
  • URL : The URL of the file you wish to be placed into your MediaFire account.
  • filename : The name you want MediaFire to assign to the file from the given URL.

Optional Parameters
  • signature : This is the call signature that is required to authenticate a type 2 session token transaction.
  • folder_key : The key that identifies the destination folder. If not passed, then it will return the root folder (session token is then required).
  • response_format : 'xml' or 'json' (default 'xml')


GET http://www.mediafire.com/api/1.0/upload/add_web_upload.php
POST http://www.mediafire.com/api/1.0/upload/add_web_upload.php

Example:

Request
http://www.mediafire.com/api/1.0/upload/add_web_upload.php?session_token=0123456789012345678901234567890123456789&url=http%3A%2F%2Fwww.website.com%2Frevenue_2013.doc&filename=mydocument.doc
                        
Response
<response>
  <action>upload/add_web_upload</action>
  <upload_key>kf94jf5ndp</upload_key>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        

Check


Description: Checks if a duplicate filename exists in the destination folder and verifies folder permissions for non-owner uploads. When a hash is supplied, hash_exists is returned to indicate whether an instant upload is possible. Several flags are returned, which can be "yes" or "no": file_exists (with the same name and location), different_hash (if file_exists), hash_exists (somewhere in the cloud), in_account (if hash_exists), and in_folder (if hash_exists). If a path is supplied, a folder_key will also be returned to be used for a subsequent upload. If resumable is supplied as "yes", a resumable upload will be initiated, and resumable_upload will be returned containing the relevant data.


Required Parameters

  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature).
  • filename : File name is required to be UTF-8 encoded. Filename is not required if both hash and size are passed.

Optional Parameters
  • signature : This is the call signature that is required to authenticate a type 2 session token transaction.
  • folder_key: The destination folder to store the file. If it's not passed, then the file will be stored in the root folder.
  • filedrop_key : This is the key of the file drop to upload to. This parameter is honored only if folder_key is not passed.
  • size : File size in bytes. This needs to be passed if hash is passed. Required if resumable="yes".
  • hash : SHA-256 hash of the file. If not passed, no content checks can be made. Required if resumable="yes".
  • path : The path relative to folder_key where the file should be uploaded.
  • resumable : Indicates whether this upload can be resumed. "yes" or "no" (default "no").
  • response_format : 'xml' or 'json' (default 'xml')


GET http://www.mediafire.com/api/1.0/upload/check.php
POST http://www.mediafire.com/api/1.0/upload/check.php

Example 1: The file already exits.

Request
http://www.mediafire.com/api/1.0/upload/check.php?session_token=123456789012345678901234567890123456789012345678901234567890&filename=uploaded%5fby%5fhash%2ezip&hash=65dd21d705d5680cf7777286d627de9e799ef03e2ff0374df297382e3f1cd1d1&size=34221
                        
Response
<response>
  <action>upload/check</action>
  <hash_exists>yes</hash_exists>
  <in_account>yes</in_account>
  <in_folder>yes</in_folder>
  <file_exists>yes</file_exists>
  <different_hash>no</different_hash>
  <duplicate_quickkey>32d392v90o3pvd3</duplicate_quickkey>
  <available_space>205819035105</available_space>
  <used_storage_size>70132613663</used_storage_size>
  <storage_limit>275951648768</storage_limit>
  <storage_limit_exceeded>no</storage_limit_exceeded>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        

Example 2: The user has run out of storage space.

Request
http://www.mediafire.com/api/1.0/upload/check.php?session_token=123456789012345678901234567890123456789012345678901234567890&filename=uploaded%5fby%5fhash%2ezip&hash=65dd21d705d5680cf7777286d627de9e799ef03e2ff0374df297382e3f1cd1d1&size=34221
                        
Response
<response>
  <action>upload/check</action>
  <hash_exists>no</hash_exists>
  <file_exists>no</file_exists>
  <available_space>0</available_space>
  <used_storage_size>54882441579</used_storage_size>
  <storage_limit>53687091200</storage_limit>
  <storage_limit_exceeded>yes</storage_limit_exceeded>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        

Example 3: This is a resumable upload.

Request
http://www.mediafire.com/api/1.0/upload/check.php?session_token=123456789012345678901234567890123456789012345678901234567890&filename=my_document.doc&hash=68dd21d705d5680cf7777286d627de9e799ef03e2ff0374df297382e3f1cd1d1&size=34221&resumable=yes
                        
Response
<response>
  <action>upload/check</action>
  <hash_exists>no</hash_exists>
  <file_exists>no</file_exists>
  <resumable_upload>
    <all_units_ready>no</all_units_ready>
    <number_of_units>28</number_of_units>
    <unit_size>2097152</unit_size>
    <bitmap>
      <count>2</count>
      <words>
        <word>1258</word>
        <word>495</word>
      </words>
    </bitmap>
  </resumable_upload>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        


Get Options


Description: Get upload preferences. Preferences include the following data: disable_flash, disable_html5, disable_instant, action_on_duplicate, used_storage_size, storage_limit, and storage_limit_exceeded.

Required Parameters


Optional Parameters
  • signature : This is the call signature that is required to authenticate a type 2 session token transaction.
  • response_format : 'xml' or 'json' (default 'xml')


GET http://www.mediafire.com/api/1.0/upload/get_options.php
POST http://www.mediafire.com/api/1.0/upload/get_options.php

Example:

Request
http://www.mediafire.com/api/1.0/upload/get_options.php?session_token=0123456789012345678901234567890123456789
                        
Response
<response>
  <action>upload/get_options</action>
  <disable_flash>no</disable_flash>
  <disable_html5>yes</disable_html5>
  <disable_instant>yes</disable_instant>
  <action_on_duplicate>keep</action_on_duplicate>
  <used_storage_size>2917435403</used_storage_size>
  <storage_limit>268435456000</storage_limit>
  <storage_limit_exceeded>no</storage_limit_exceeded>
  <result>Success</result>
  <current_api_version>2.12</current_api_version>
</response>
                        

Get Web Uploads


Description: Returns a list of web uploads currently in progress or all web uploads.


Required Parameters


Optional Parameters
  • signature : This is the call signature that is required to authenticate a type 2 session token transaction.
  • all_web_uploads : Whether or not to return all web uploads, or just the active ones. 'yes' or 'no' (default 'no').
  • response_format : 'xml' or 'json' (default 'xml')


GET http://www.mediafire.com/api/1.0/upload/get_web_uploads.php
POST http://www.mediafire.com/api/1.0/upload/get_web_uploads.php

Example:

Request
http://www.mediafire.com/api/1.0/upload/get_web_uploads.php?session_token=0123456789012345678901234567890123456789&all_web_uploads=yes
                        
Response
<response>
  <action>upload/get_web_uploads</action>
  <web_uploads>
    <web_upload>
      <uploadkey>1buf74mkf8</uploadkey>
      <active>yes</active>
      <filename>presentation_2013.ppt</filename>
      <created>2013-03-04 01:30:12</created>
      <status_code>3</status_code>
      <status>Transfer is in progress</status>
      <url>https://plsx.google.com/pl/us/en/dd?f=mnv45kj23vm52nbm52b45vm245&sr=s611</url>
      <eta>1.27 minutes</eta>
      <size>350852621</size>
      <percentage>36</percentage>
    </web_upload>
    <web_upload>
      <uploadkey>podf2b4yiz</uploadkey>
      <active>no</active>
      <filename>FireFox.4.0.rar</filename>
      <created>2013-03-05 15:37:20</created>
      <status_code>6</status_code>
      <status>Verifying transfer</status>
      <url>https://www.download.com/xyd2h7pni897omy/dl.php?to=dR09BH3UYQPuYHsWefdFu2IReu2DtWOkKO7g&rand=6987641</url>
      <eta>Transfer completed</eta>
      <size>310597201</size>
      <percentage>100</percentage>
    </web_upload>
  </web_uploads>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        

Instant


Description: Attempts to match the hash and size of a file with an existing file in the could and "upload" to the user's account by copying this already uploaded file. Returns a quickkey on successful instant upload.

Required Parameters

  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature).
  • filename : File name is required to be UTF-8 encoded. Filename is not required if both hash and size are passed.
  • size : File size in bytes. This needs to be passed if hash is passed. Required if resumable="yes".
  • hash : SHA-256 hash of the file. If not passed, no content checks can be made. Required if resumable="yes".

Optional Parameters
  • signature : This is the call signature that is required to authenticate a type 2 session token transaction.
  • quick_key :To update an existing file, pass its quickkey.
  • folder_key: The destination folder to store the file. If it's not passed, then the file will be stored in the root folder.
  • filedrop_key : This is the key of the file drop to upload to. This parameter is honored only if folder_key is not passed.
  • path : The path relative to folder_key where the file should be uploaded.
  • action_on_duplicate : When a file with the same name is encountered in the same folder, this determines how the conflict is resolved. Possible values are "skip" to ignore the upload (default), "keep" to keep both files with a new one with a number appended, and "replace" to overwrite the old file adding to its version history.
  • mtime :
  • version_control : Specify version control. This takes effect only on a file update. Can take the following values: "keep_revision" (default), to keep the version being updated, and "none", to overwrite the version being updated.
  • previous_hash : This is the hash of the last known version of the file before it was modified. This parameter can only be used on update uploads, that is, when passing quickkey to overwrite an existing file on the cloud. If the previous hash is different from the current version on the cloud, then there is a conflict, and the file will be uploaded as a new file with a new quickkey and filename.
  • response_format : 'xml' or 'json' (default 'xml')


GET http://www.mediafire.com/api/1.0/upload/instant.php
POST http://www.mediafire.com/api/1.0/upload/instant.php

Example 1: Uploading a new file

Request
http://www.mediafire.com/api/1.0/upload/instant.php?session_token=6b6476c0c4f100310f0ae0a9800b8ba839341e6767c3c1a6290a8da3f8a9023d091775c72ad536d9ef4017f990c5fb3d1d242b1b53debe54a0dcf51d931ec0a2af425480d9f74758&filename=whatever.gif&hash=48e1d9e64608ec4d720e5d325b8ddbfcda82edc10a347c3307fedd464f39cee7&size=271228&folder_key=1m5v2f6hdtsa9
                        
Response
<response>
  <action>upload/instant</action>
  <quickkey>32d392v90o3pvd3</quickkey>
  <filename>whatever.gif</filename>
  <newrevision>
    <revision>2.77</revision>
    <epoch>1392312822</epoch>
  </newrevision>
  <newfolderrevision>
    <revision>123</revision>
    <epoch>1392670667</epoch>
  </newfolderrevision>
  <result>Success</result>
  <device_revision>22551</device_revision>
  <current_api_version>1.0</current_api_version>
</response>
                        

Example 2: Updating an existing file

Request
http://www.mediafire.com/api/1.0/upload/instant.php?session_token=6b6476c0c4f100310f0ae0a9800b8ba839341e6767c3c1a6290a8da3f8a9023d091775c72ad536d9ef4017f990c5fb3d1d242b1b53debe54a0dcf51d931ec0a2af425480d9f74758&hash=a342ebb034db724498457f0fab9d9336eb8cd2acd9e11c6502ca614f74a7de69&size=728508&quickkey=32d392v90o3pvd3&folder_key=1m5v2f6hdtsa9
                        
Response
<response>
  <action>upload/instant</action>
  <quickkey>32d392v90o3pvd3</quickkey>
  <filename>whatever.gif</filename>
  <newrevision>
    <revision>2.77</revision>
    <epoch>1392312822</epoch>
  </newrevision>
  <newfolderrevision>
    <revision>123</revision>
    <epoch>1392670667</epoch>
  </newfolderrevision>
  <result>Success</result>
  <device_revision>22554</device_revision>
  <current_api_version>1.0</current_api_version>
</response>
                        

Example 3: Uploading a new file when a file already exists with that name

Request
http://www.mediafire.com/api/1.0/upload/instant.php?session_token=0123456789012345678901234567890123456789&all_web_uploads=yes
                        
Response
<response>
  <action>upload/instant</action>
  <quickkey>u4azx8jq238p75l</quickkey>
  <filename>whatever(2).gif</filename>
  <newrevision>
    <revision>2.78</revision>
    <epoch>1392312822</epoch>
  </newrevision>
  <newfolderrevision>
    <revision>124</revision>
    <epoch>1392670667</epoch>
  </newfolderrevision>
  <result>Success</result>
  <device_revision>22559</device_revision>
  <current_api_version>1.0</current_api_version>
</response>
                        


Patch


Description: Update an existing file in the user's account with a patch. The uploaded patch will be used to patch the existing file to generate a new file that will override the patched file. This API returns the upload key when successful. You will have to pass this key to upload/poll_upload.php to check the final result of the patch update upload. Please refer to the documentation about the API upload/poll_upload for more details.


Required Parameters
POST Body

  • source_hash : The hash of the file to be patched.
URL Query Data
  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature). Required if not uploading to a FileDrop. Alternatively, a valid action token may be used instead.
  • quick_key : The quickkey of the file to update. The uploaded file content will be used to patch then override an existing file's current revision defined by the passed quickkey
  • source_hash : The hash of the file to be patched.
  • target_hash : The expected hash of the target file.
  • target_size : The expected size of the target file.

Optional Parameters
URL Query Data
  • mtime : The date/time of the update. If not set, the current server time will be used. Refer to the following document for valid date/time formats: http://www.php.net/manual/en/datetime.formats.php
  • version_control : Specify version control. This takes effect only on a file update. Can take the following values: "keep_revision" (default), to keep the version being updated, and "none", to overwrite the version being updated.
  • previous_hash : This is the hash of the last known version of the file before it was modified. This is honored only on update uploads, that is, when passing quickkey to overwrite an existing file on the cloud. If the previous hash is different from the current version on the cloud, then there is a conflict, and the file will be uploaded as a new file with a new quickkey and filename.


Return values:
result
  • -14 : Upload failed because the folder specified does not exist.
  • -31, -40 : Unknown upload error.
  • -32 : Missing file data.
  • -41 : The uploaded file exceeds the upload_max_filesize.
  • -42 : The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
  • -43 : The uploaded file was only partially uploaded.
  • -44 : No file was uploaded.
  • -45 : Missing a temporary folder.
  • -46 : Failed to write file to disk.
  • -47 : A PHP extension stopped the file upload.
  • -48 : Invalid file size.
  • -49 : Missing file name.
  • -51 : File size does not match size on disk.
  • -90 : The supplied hash does not match the actual hash of the file.
  • -99 : Missing or invalid session token.
  • -203 : Invalid quickkey or file does not belong to session user.
  • -204 : User does not have write permissions to this file.
  • -205 : User does not have write permissions to the destination folder.
  • -206 : The destination folder has been moved to the Trash.
  • -701, -881 : Maximum file size for free users exceeded.
  • -700, -882: Maximum file size exceeded.
  • -10, -12, -26, -50, -52, -53, -54, -70, -71, -80, -120, -122, -124, -140, -200 : Internal server error.

GET http://www.mediafire.com/api/1.0/upload/patch.php
POST http://www.mediafire.com/api/1.0/upload/patch.php

Example:

Request Using an HTML Form
<form method="POST" enctype="multipart/form-data" encoding="multipart/form-data" action="http://www.mediafire.com/api/1.0/upload/patch.php?quickkey=d48npvto349n5vp&source_hash=db0db0d90bcfd98b087b03720d70d987bc0987bc02e97b0220db70d297bc29b9&target_hash=c61098bfe4e40dc5bd3643d3cb4d95cdbdfb22dfc2dc7f64527d6fcdfcbd7fcb&target_size=64522&session_token=123456789012345678901234567890123456789012345678901234567890">
    <input type="file" name="Filedata" />
    <input type="submit" />
</form>
Response
<response>
  <action>upload/patch</action>
  <doupload>
    <result>0</result>
    <key>5gpwdo7p59g</key>
  </doupload>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        

Perform a Patch Upload

This features allows the client to upload a delta file (patch) to update the content of an existing file instead of uploading the entire file. To update a file with a patch, four additional GET arguments need to be passed:

  • quick_key : The quickkey of the file being patched/updated.
  • source_hash : The hash of the file being patched/updated.
  • target_hash : A SHA256 check-sum of the target file.
  • target_size : The size of the target file.

The patch file should be created on the client-side using the same algorithm used by xdelta 3. Please check http://xdelta.org/ for more details.


Poll Upload


Description: Check for the status of a current Upload. This can be called after using any of the upload family of APIs which return an upload key. Use the key returned (response.doupload.key) to request the status of the current upload. Keep calling this API every few seconds until you get the status value 99 which means that the upload is complete. The quickkey of the file and other related information is also returned when the upload is complete.


Required Parameters

  • key : The key from the current upload, returned after using any of the upload family of APIs which return an upload key.

Optional Parameters
  • response_format : 'xml' or 'json' (default 'xml')


Return Values:

result

  • 0 : Success
  • -20 : Invalid Upload Key
  • -80 : Upload Key not found
status
  • 2 : Key is ready for use
  • 3 : Upload is in progress
  • 4 : Upload is completed
  • 5 : Waiting for verification
  • 6 : Verifying File
  • 11 : Finished verification
  • 17 : Upload is in progress
  • 18 : Waiting for assembly
  • 19 : Assembling File
  • 99 : No more requests for this key
  • 0 : Unknown or no status available for this key
fileerror
  • 1 : File is larger than the maximum filesize allowed
  • 2 : File size cannot be 0
  • 3 : Found a bad RAR file
  • 4 : Found a bad RAR file
  • 5 : Virus found
  • 6 : Unknown internal error
  • 7 : File hash or size mismatch
  • 8 : Unknown internal error
  • 9 : Found a bad RAR file
  • 10 : Unknown internal error
  • 12 : Failed to insert data into database
  • 13 : File name already exists in the same parent folder, skipping
  • 14 : Destination folder does not exist
  • 15 : Account storage limit is reached
  • 16 : There was a file update revision conflict
  • 17 : Error patching delta file
  • 18 : Account is blocked
  • 19 : Failure to create path


GET http://www.mediafire.com/api/1.0/upload/poll_upload.php
POST http://www.mediafire.com/api/1.0/upload/poll_upload.php

Example:

Request
http://www.mediafire.com/api/upload/poll_upload.php?key=cl66s5mhas6
                        
Response
<response>
    <action>upload/poll_upload</action>
    <doupload>
        <result>0</result>
        <status>99</status>
        <description>No more requests for this key</description>
        <fileerror/>
        <quickkey>l86be19e1nrla8p</quickkey>
        <size>1334903</size>
        <revision>1.6</revision>
    </doupload>
    <result>Success</result>
    <current_api_version>1.0</current_api_version>
</response>
                        

Pre Upload (deprecated)


Deprecated. Use upload/check and upload/instant instead.

Description: Determines if instant upload is possible, if a duplicate filename exists in the destination folder, and also verifies folder permissions for non-owner uploads. This returns a 'quickkey' on successful instant upload. Otherwise, 'new_hash' and 'duplicate_name' are returned, which can be 'yes' or 'no'. Based on those values, the uploader performs a regular upload or resends the same pre_upload request with the desired action. If 'path' is specified and an instant upload was not possible, the 'folder_key' will also be returned to be used for a regular upload.View a flow chart of the upload process.


Required Parameters

  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature).
  • filename : File name UTF-8 encoded. This is not required if quick_key and hash are passed.

Optional Parameters
  • signature : This is the call signature that is required to authenticate a type 2 session token transaction.
  • hash : SHA256 hash of file, if not passed, only duplicate name is checked.
  • size : File size. This must passed if hash is passed.
  • mtime : The date/time of the update. If not set, the current server time will be used. Refer to the following document for valid date/time formats: http://www.php.net/manual/en/datetime.formats.php
  • upload_folder_key : The folderkey of the folder you wish to upload your file to. If not passed, the destination folder is the root folder.
  • quick_key : To update an existing file, pass the quickkey of that file. A file update requires hash to be passed too, otherwise quick_key is ignored.
  • filedrop_key : This is the key of the file drop to upload to. This parameter is honored only if upload_folder_key is not passed.
  • action_on_duplicate : This is used in the case where there are duplicate file names in the same upload folder. The values are 'keep' (default) (to keep both files with the same name, the new file will have a numeric digit added to it), 'skip' (this will ignore the upload), and 'replace' (this will override the original file with the new file).
  • resumable : In the circumstance of the upload being interrupted, this indicates whether this upload can be resumed. 'yes' or 'no' (default 'no').
  • path : The path relative to 'folder_key' where the file should be uploaded. Any folders specified will be created if they do not exist.
  • response_format : 'xml' or 'json' (default 'xml')

Errors:
  • 114 - Non-owner upload does not have write permissions to the folder.


GET http://www.mediafire.com/api/1.0/upload/pre_upload.php
POST http://www.mediafire.com/api/1.0/upload/pre_upload.php

Example 1:

Request
http://www.mediafire.com/api/1.0/upload/pre_upload.php?session_token=123456789012345678901234567890123456789012345678901234567890&filename=uploaded%5fby%5fhash%2ezip&hash=65dd21d705d5680cf7777286d627de9e799ef03e2ff0374df297382e3f1cd1d1&size=34221&upload_folder_key=f7a1ec50dcbbe&action_on_duplicate=replace
                        
Response
<response>
  <action>upload/pre_upload</action>
  <newrevision>
      <revision>1.113</revision>
      <epoch>1352305437</epoch>
  </newrevision>
  <newfolderrevision>
      <revision>79</revision>
      <epoch>1352305451</epoch>
  </newfolderrevision>
  <quickkey>276hrbqba55zz7h</quickkey>
  <device_revision>123</device_revision>
     <deprecated>yes</deprecated>
  <result>Success</result>
  <current_api_version>2.12</current_api_version>
</response>
                        

Example 2:

Request
http://www.mediafire.com/api/1.0/upload/pre_upload.php?session_token=123456789012345678901234567890123456789012345678901234567890&filename=my_document.doc&hash=68dd21d705d5680cf7777286d627de9e799ef03e2ff0374df297382e3f1cd1d1&size=34221&resumable=yes
                        
Response
<response>
  <action>upload/pre_upload</action>
  <new_hash>yes</new_hash>
  <duplicate_name>no</duplicate_name>
  <resumable_upload>
    lt;all_units_ready>no</all_units_ready>
    <number_of_units>28</number_of_units>
    <unit_size>2097152</unit_size>
    <bitmap>
        <count>2</count>
        <words>
            <word>1258</word>
            <word>495</word>
        </words>
    </bitmap>
  </resumable_upload>
  <deprecated>yes</deprecated>
  <result>Success</result>
  <current_api_version>2.12</current_api_version>
</response>
                        

Example 3 (In this example, we assume that the user has run out of storage space):

Request
http://www.mediafire.com/api/1.0/upload/pre_upload.php?session_token=123456789012345678901234567890123456789012345678901234567890&filename=uploaded%5fby%5fhash%2ezip&hash=65dd21d705d5680cf7777286d627de9e799ef03e2ff0374df297382e3f1cd1d1&size=34221
                        
Response
<response>
  <action>upload/pre_upload</action>
  <duplicate_name>no</duplicate_name>
  <used_storage_size>54882441579</used_storage_size>
  <storage_limit>53687091200</storage_limit>
  <storage_limit_exceeded>yes</storage_limit_exceeded>
  <deprecated>yes</deprecated>
  <result>Success</result>
  <current_api_version>2.12</current_api_version>
</response>
                        

Resumable


Definition: Resumes an upload that was interrupted. Upload a unit/chunk of a file as part of a resumable upload to the user's account. Uploading large files through upload/simple can take a long time, and if it fails, re-uploading the file starts from the beginning--unlike a resumable upload, which allows you to upload the file in small units or chunks. So if one unit fails to upload, only that unit is re-uploaded. upload/resumable can only be called after a call to upload/check which initiates the resumable upload. This API returns the upload key when successful. After you upload all the units, you can pass the key to upload/poll_upload to get the quickkey. Please refer to the documentation about the API upload/poll_upload for more details.

Required Parameters:
POST Body

  • Multipart MIME headers
  • Binary file data
(see Uploading Concepts for more details)

URL Query Data
  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature). Required if not uploading to a FileDrop. Alternatively, a valid action token may be used instead.

Header Data
  • x-filesize : File size of the file.
  • x-filehash : A SHA256 hash of the file. Hash must be supplied in lower-case.
  • x-unit-hash : A SHA256 hash of the unit being uploaded.
  • x-unit-id : An ID of the unit. Can be 0 through Number of units - 1
  • x-unit-size : The size of the unit being uploaded.

Optional Parameters
URL Query Data
  • quick_key : If a quickkey is passed during the upload of the first unit, the final uploaded file content will override an existing file's current revision defined by the passed quickkey. The file is updated only after all the units are uploaded.
  • action_on_duplicate : Specifies the action to take when the file already exists, by name, in the destination folder. Options are skip (default), keep, & replace. Skip ignores the upload. Keep uploads the file and makes the file name unique by appending a number to it. Replace overwrites the old file, possibly adding to its version history.
  • mtime : The date/time of the update. If not set, the current server time will be used. Refer to the following document for valid date/time formats: http://www.php.net/manual/en/datetime.formats.php
  • version_control : Specify version control. This takes effect only on a file update. Can take the following values: create_patches (default) to create the forward and reverse patches to and from the revision being updated, keep_revision to keep the revision being updated and no patches are created, and none will not create patches and will not keep the updated revision.
  • folder_key: The folder key of the folder where the file is to be stored. If it's not passed, then the file will be stored in the root folder.
  • filedrop_key : The FileDrop key where the file is to be stored. This is an encrypted string, not the normal 13-character folder key.
  • path : The path relative to folder_key where the file should be uploaded. Any folders specified will be created if they do not exist.
  • previous_hash : This is the hash of the last known version of the file before it was modified. This parameter can only be used on update uploads, that is, when passing quickkey to overwrite an existing file on the cloud. If the previous hash is different from the current version on the cloud, then there is a conflict, and the file will be uploaded as a new file with a new quickkey and filename.

Additional POST argument if the file being uploaded is a delta file to patch an existing file. Required when 'quickkey' is passed.
  • source_hash : The hash of the file to be patched.
  • target_hash : The expected hash of the target file.
  • target_size : The expected size of the target file.

To perform a successful resumable upload, follow these steps :
  • Call upload/check and pass the session_token, filename, hash, size, and resumable=yes.
    • This call will return a set of data under resumable_upload object which are : unit_size, number_of_units, bitmap.
    • unit_size is the size in bytes of the file units to be uploaded at a time. All chunks, except the last one, have to have a size equal to unit_size.
    • number_of_units is the total number of units that compose the entire file.
    • bitmap is an array of 16-bit values. Each value represents 16 chucks. Each bit indicates whether a unit is uploaded or not. For example - a value 19 which, is 10011 in binary, indicates that units 0, 1 and 4 are uploaded.
  • Break the file into chunks of unit_size bytes for each unit that is still not uploaded according to bitmap:
    • Calculate the SHA256 hash of the unit.
    • Call upload/resumable API and pass the unit as well as the following arguments:
      • POST Arguments: session_token, and uploadkey (optional)
      • Header Arguments:
        • x-filesize: The size of the entire file.
        • x-filehash: A SHA256 hash of the entire file. Hash must be supplied in lower-case.
        • x-unit-id: The ID of the unit (0 to number_of_units - 1).
        • x-unit-hash: The SHA256 hash of the unit
        • x-unit-size: The size of the unit being uploaded.
    • To check if all units are uploaded, call upload/pre_upload again. Under resumable_upload object, check whether all_units_ready is set to yes or no.
    • Once all units are uploaded, proceed to call upload/poll_upload every few seconds until you get the quickkey of the file.

Decoding the Bitmap


Below is a JavaScript function that can be used to decode the bitmap returned by upload/pre_upload API:
/**
 * Decodes the bitmap returned by the upload/pre_upload api call (response.resumable_upload.bitmap)
 * Returns an array of units, the index being the unit's id and the value being a boolean indicating whether the unit is uploaded or not
 */
function decodeBitmap(bitmap) {
    var uploadUnits = [];
    for (var i = 0; i < bitmap.count; i++) {
        var word = parseInt(bitmap.words[i], 10);
        var bin = word.toString(2);
        while(bin.length < 16)
            bin = "0" + bin;
        for(var b = 0; b < bin.length; b++)
            uploadUnits[i * 16 + b] = (bin[15 - b] == "1");
    }
    return uploadUnits;
}


// Let's assume the API returned a JSON response which contains a bitmap under (response.resumable_upload.bitmap) having 2 words with values 17 and 32.
bitmap = {count: 2, words: [17, 32]};

var unitUploaded = decodeBitmap(bitmap);

alert(unitUploaded[0]); // true
alert(unitUploaded[3]); // false
alert(unitUploaded[4]); // true
alert(unitUploaded[21]); // true
alert(unitUploaded[22]); // false
                        

Example:

Request
http://www.mediafire.com/api/1.0/upload/resumable.php?folder_key=icbju4kjukdw2&session_token=02d6424739b785c84203b6a1302857c38d2bb34f464a04c156ceee7c72179871f71a8ff5b6c16fc6d0b728df6554be6a8e715a09eb99fc123fe214c3e15cfce79f8a2d0bdd04df2d
                        
Response
<response>
  <action>upload/resumable.php</action>
  <doupload>
    <result>0</result>
    <key>b7bpiovaoyv</key>
  </doupload>
  <resumable_upload>
    <all_units_ready>no</all_units_ready>
    <bitmap>
      <count>1</count>
      <words>
        <word>0</word>
          </words>
      </bitmap>
      <number_of_units>1</number_of_units>
      <unit_size>4194304</unit_size>
  </resumable_upload>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        

Set Options


Description: This API will set the user's preferences for uploads when using the JavaScript Upload client on the MediaFire website.


Required Parameters

  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature).
  • filename : Indicate the filename. Must be in UTF-8 encoded.

Optional Parameters
  • signature : This is the call signature that is required to authenticate a type 2 session token transaction.
  • disable_flash : To disable Flash uploads 'yes' or 'no'.
  • disable_html5 : To disable HTML5 uploads 'yes' or 'no'.
  • disable_instant : To disable instant uploads. Instant uploads works only when HTML5 uploads are enabled. 'yes' or 'no'.
  • action_on_duplicate : This is used in the case where there are duplicate file names in the same upload folder. The values are 'keep' (to keep both files with the same name, the new file will have a numeric digit added to it), 'skip' (this will ignore the upload), and 'replace' (this will override the original file with the new file). If not passed, then no action will be performed on duplicate names and a flag 'duplicate_name' is set to 'yes' requesting the action to be passed.
  • response_format : 'xml' or 'json' (default 'xml')

GET http://www.mediafire.com/api/1.0/upload/set_options.php
POST http://www.mediafire.com/api/1.0/upload/set_options.php

Example:

Request
http://www.mediafire.com/api/1.0/upload/set_options.php?session_token=749e4610d9e719620a1e9347ca9aabe5f86ac58d67c8bdd85f0eb4e043624ac70ec1a3f88dd49bb8126ad4c38a7686665ec66d727207ac1a99e9dc6c5cdf0772da405c3464c2d2af&disable_flash=yes&disable_instant=yes
                        
Response
<response>
  <action>upload/set_options</action>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        

Simple


Description: Upload a new file through POST to the user's account. You can either use the session token to authenticate the user, or pass the FileDrop folder key. This API returns the upload key when successful. You will have to pass this key to upload/poll_upload to get the quickkey. Please refer to the documentation about the API upload/poll_upload for more details.


Required Parameters:
POST Body

  • Multipart MIME headers
  • Binary file data
(see Uploading Concepts for more details)

Optional Parameters
URL Query Data
  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature).
  • folder_key: The destination folder to store the file. If it's not passed, then the file will be stored in the root folder.
  • path : The path relative to folder_key where the file should be uploaded.
  • filedrop_key : This is the key of the file drop to upload to. This parameter is honored only if folder_key is not passed.
  • action_on_duplicate : Specifies the action to take when the file already exists, by name, in the destination folder. skip ignores the upload, keep uploads the file and makes the file name unique by appending a number to it, and replace overwrites the old file, possibly adding to its version history. The default is to use the user's preference set through upload/set_options. If the user has not set a default then skip is used. skip (default), keep, replace.
  • mtime : The date/time of the update. If not set, the current server time will be used. Refer to the following document for valid date/time formats: http://www.php.net/manual/en/datetime.formats.php

Header Data
  • x-filename : File name you want to name the file on the system. See Uploading Concepts for more details.


Return values:
Result
  • -1, -8, -11 : FileDrop key is invalid.
  • -14 : Upload failed because the folder specified does not exist.
  • -21, -22 : Invalid FileDrop configuration.
  • -31, -40 : Unknown upload error.
  • -32 : Missing file data.
  • -41 : The uploaded file exceeds the upload_max_filesize.
  • -42 : The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
  • -43 : The uploaded file was only partially uploaded.
  • -44 : No file was uploaded.
  • -45 : Missing a temporary folder.
  • -46 : Failed to write file to disk.
  • -47 : A PHP extension stopped the file upload.
  • -48 : Invalid file size.
  • -49 : Missing file name.
  • -51 : File size does not match size on disk.
  • -90 : The supplied hash does not match the actual hash of the file.
  • -99 : Missing or invalid session token.
  • -205 : User does not have write permissions to the destination folder.
  • -206 : The destination folder has been moved to the Trash.
  • -701, -881 : Maximum file size for free users exceeded.
  • -700, -882: Maximum file size exceeded.
  • -10, -12, -26, -50, -52, -53, -54, -70, -71, -80, -120, -122, -124, -140, -200 : Internal server error.

GET http://www.mediafire.com/api/1.0/upload/simple.php
POST http://www.mediafire.com/api/1.0/upload/simple.php

Example:

Request Using an HTML Form
<form method="POST" enctype="multipart/form-data" encoding="multipart/form-data" action="http://www.mediafire.com/api/1.0/upload/simple.php?session_token=123456789012345678901234567890123456789012345678901234567890">
    <input type="file" name="Filedata" />
    <input type="submit" />
</form>
                            
                        
Response
<response>
  <action>upload/simple</action>
  <doupload>
    <result>0</result>
    <key>qpcnocpg1cm</key>
  </doupload>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        


Update


Description: Update an existing file in the user's account with another file. This API returns the upload key when successful. You will have to pass this key to upload/poll_upload.php to check the final result of the update upload. Please refer to the documentation about the API upload/poll_upload for more details.


Required Parameters:
POST Body

  • Multipart MIME headers
  • Binary file data
(see Uploading Concepts for more details)

URL Query Data
  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature). Required if not uploading to a FileDrop. Alternatively, a valid action token may be used instead.
  • quick_key : The quickkey of the file to update. The uploaded file content will be used to patch then override an existing file's current revision defined by the passed quickkey.

Optional Parameters
URL Query Data
  • mtime : The date/time of the update. If not set, the current server time will be used. Refer to the following document for valid date/time formats: http://www.php.net/manual/en/datetime.formats.php
  • previous_hash : This is the hash of the last known version of the file before it was modified. This is honored only on update uploads, that is, when passing quickkey to overwrite an existing file on the cloud. If the previous hash is different from the current version on the cloud, then there is a conflict, and the file will be uploaded as a new file with a new quickkey and filename.


Return values:
result
  • -14 : Upload failed because the folder specified does not exist.
  • -31, -40 : Unknown upload error.
  • -32 : Missing file data.
  • -41 : The uploaded file exceeds the upload_max_filesize.
  • -42 : The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
  • -43 : The uploaded file was only partially uploaded.
  • -44 : No file was uploaded.
  • -45 : Missing a temporary folder.
  • -46 : Failed to write file to disk.
  • -47 : A PHP extension stopped the file upload.
  • -48 : Invalid file size.
  • -49 : Missing file name.
  • -51 : File size does not match size on disk.
  • -90 : The supplied hash does not match the actual hash of the file.
  • -99 : Missing or invalid session token.
  • -203 : Invalid quickkey or file does not belong to session user.
  • -204 : User does not have write permissions to this file.
  • -205 : User does not have write permissions to the destination folder.
  • -206 : The destination folder has been moved to the Trash.
  • -701, -881 : Maximum file size for free users exceeded.
  • -700, -882: Maximum file size exceeded.
  • -10, -12, -26, -50, -52, -53, -54, -70, -71, -80, -120, -122, -124, -140, -200 : Internal server error.

GET http://www.mediafire.com/api/1.0/upload/update.php
POST http://www.mediafire.com/api/1.0/upload/update.php

Example:

Request Using an HTML Form
<form method="POST" enctype="multipart/form-data" encoding="multipart/form-data" action="http://www.mediafire.com/api/1.0/upload/update.php?quickkey=iej48fhty23yehe&session_token=123456789012345678901234567890123456789012345678901234567890">
    <input type="file" name="Filedata" />
    <input type="submit" />
</form>
Response
<response>
  <action>upload/update</action>
  <action>doupload>
    <result>0</result>
    <key>qmn5v92c5yv</key>
  </doupload>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>
                        


Upload (deprecated)


Deprecated. Use upload/simple, upload/resumable, upload/update, or upload/patch instead.

Description: Upload a file through POST to the user's account. You can either use the session token to authenticate the user, or pass the dropbox key. This api returns the upload key when successful. You will have to pass this key to upload/poll_upload.php to get the quickkey. Please refer to the documentation about the API upload/poll_upload for more details. View a flow chart of the upload process.


Required Parameters:
POST Body

  • Multipart MIME headers
  • Binary file data
(see Uploading Concepts for more details)

Header Data
  • x-filename : File name you want to name the file on the system. See Uploading Concepts for more details.

Optional Parameters
URL Query Data
  • uploadkey : The folder_key of the folder where to store the file. If it's not passed, then the file will be stored in the root folder. In FileDrop mode, this would be the FileDrop key.
  • session_token : A type 1 or type 2 session token. (Type 2 will require a call signature). Required if not uploading to a dropbox. Alternatively, a valid action token may be used instead.
  • quick_key : If a quickkey is passed, the uploaded file content will overwrite an existing file's current revision defined by the passed quickkey. Quickkey is also required when uploading a delta file to patch an existing file.
  • mtime : The date/time of the update. If not set, the current server time will be used. Refer to the following document for valid date/time formats: http://www.php.net/manual/en/datetime.formats.php
  • action_on_duplicate : Specifies the action to take when the file already exists, by name, in the destination folder. Options are skip, keep (default), & replace. Skip ignores the upload. Keep uploads the file and makes the file name unique by appending a number to it. Replace overwrites the old file, possibly adding to its version history.
  • filedrop : Set to '1' to enable FileDrop mode. If enabled, the uploadkey must be the FileDrop key, which is an encrypted string, not the normal 13-character folder key. For backward compatibility, dropbox is still accepted as an alias for this parameter.
  • version_control : Specify version control. This takes effect only on a file update. Can take the following values: create_patches (default) to create the forward and reverse patches to and from the revision being updated, keep_revision to keep the revision being updated and no patches are created, and none will not create patches and will not keep the updated revision.
  • path : The path relative to 'uploadkey' where the file should be uploaded. Any folders specified will be created if they do not exist.
  • previous_hash : This is the hash of the last known hash to the client of the file before it's modified. This is honored only on update uploads, that is, when passing 'quickkey' to override an existing file on the cloud. If the previous hash is different than the current version on the cloud, then this is a conflict and the file will be uploaded as a new file with new quickkey and filename.

Additional POST argument if the file being uploaded is a delta file to patch an existing file.
  • source_hash : The hash of the file to be patched
  • target_hash : The expected hash of the target file
  • target_size' : The expected size of the target file

Header Data
  • x-filesize : File size of the file.
  • x-filehash : A SHA256 hash of the file. Hash must be supplied in lower-case.

Additional arguments required if the file being uploaded is a unit (chunk/part) of a resumable upload. To initiate a resumable upload, first call upload/pre_upload API.
  • x-unit-hash : A SHA256 hash of the unit being uploaded.
  • x-unit-id : An ID of the unit. Can be 0 through Number of units - 1
  • x-unit-size : The size of the unit being uploaded.

Return values:
Result
  • -1, -8, -11 : Filedrop key is invalid
  • -14 : Upload succeeded but the folder specified does not exist, so the file was placed in the root folder
  • -21, -22 : Invalid filedrop configuration
  • -31, -40 : Unknown upload error
  • -32 : Missing file data
  • -41 : The uploaded file exceeds the upload_max_filesize
  • -42 : The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form
  • -43 : The uploaded file was only partially uploaded
  • -44 : No file was uploaded
  • -45 : Missing a temporary folder
  • -46 : Failed to write file to disk
  • -47 : A PHP extension stopped the file upload
  • -48 : Invalid file size
  • -49 : Missing file name
  • -51 : File size does not match size on disk
  • -90 : The Hash sent does not match the actual file hash
  • -99 : Missing or invalid session token
  • -203 : Invalid quickkey or file does not belong to session user
  • -204 : User does not have write permissions to this file
  • -205 : User does not have write permissions to the destination folder
  • -302 : User attempted to send a resumable upload unit before calling upload/pre_upload
  • -303 : Invalid unit size
  • -304 : Invalid unit hash
  • -701, -881 : Maximum file size for free users exceeded
  • -700, -882: Maximum file size exceeded
  • -10, -12, -26, -50, -52, -53, -54, -70, -71, -80, -120, -122, -124, -140, -200, -301 : Internal Server Errors


GET + POST http://www.mediafire.com/api/1.0/upload/upload.php
POST http://www.mediafire.com/api/1.0/upload/upload.php

Example (using an HTML form):

Request
<form method="POST" enctype="multipart/form-data" encoding="multipart/form-data" action="http://www.mediafire.com/api/1.0/upload/upload.php?session_token=123456789012345678901234567890123456789012345678901234567890">
    <input type="file" name="Filedata" />
    <input type="submit" />
</form>
                        
Response
<response>
  <action>upload/upload</action>
  <doupload>
    <result>0</result>
    <key>cl66s5mhas6</key>
  </doupload>
  <deprecated>yes</deprecated>
  <result>Success</result>
  <current_api_version>1.0</current_api_version>
</response>