Skip to content
Lodle edited this page May 13, 2014 · 4 revisions

Table of Contents

Upload MCF

This allows users to upload a mcf file in chunks.

Input

URL

 * http://api.desura.com/1/itemupload
 * username: Not Required, String. Username of a Desura account
 * password: Not Required, String. Password (or password hash) for that account

Post

 * action: Required, 20 chars max
 * sitearea: Required, must be a valid [wiki:GeneralSitearea sitearea] (supported: games, mods)
 * siteareaid: Required, Integer

if action = "newupload"

 * filehash: Required, string
 * filesize: Required, integer

if action = "resumeupload"

 * key: Required, string

if action = "uploadchunk"

 * key: Required, string
 * mcf: Required, file
 * uploadsize: Required, Integer the current chunk upload size

Process (newupload)

 1. If the username '''AND''' password is provided attempt to login the user
 1. When wanting to upload a new mcf file the upload API is called with action being '''newupload'''
   * Invalid permissions will result in a 108 (Permission Denied) being thrown.
   * Upload already started will result in a 121 (Upload already started) being thrown.
   * Invalid data will result in a 107 (validation error) being thrown.
   * If the item can not be found it will result in a 110 (item not found) being thrown.
   * Any other errors will result in a 100 (generic error) message being thrown.
 1. If valid info is provided, 0 (ok) will be returned as well as a unique key.

Process (uploadchunk)

 1. If the username '''AND''' password is provided attempt to login the user
 1. The Application starts uploading one chunk at a time calling the upload API with the action '''uploadchunk'''
   * Invalid permissions will result in a 108 (Permission Denied) being thrown.
   * Invalid data will result in a 107 (validation error) being thrown.
   * Invalid key will result in a 120 (Key doesnt match) being thrown.
   * If the item can not be found it will result in a 110 (item not found) being thrown.
   * If uploaded failed it will result in a 122 (Upload Failed) being thrown.
   * Any other errors will result in a 100 (generic error) message being thrown.
 1. If the chunk uploaded successfully, 0 (ok) will be returned.
 1. If that was the last chunk, 999 (Upload complete) will be returned instead.

Process (resumeupload)

 1. If the username '''AND''' password is provided attempt to login the user
 1. If the application has to continue a upload the upload API is called with action being '''resumeupload'''
   * Invalid permissions will result in a 108 (Permission Denied) being thrown.
   * Invalid key will result in a 120 (Key doesnt match) being thrown. 
   * If the item can not be found it will result in a 110 (item not found) being thrown.
   * Any other errors will result in a 100 (generic error) message being thrown.
 1. If the upload is not finished 0 (ok) is return as well as the current index in the file (last upload pos)

Output

0: Ok (newupload)

<?xml version="1.0" encoding="utf-8"?> 
<itemupload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="desura" version="1">
	<status code="0"/>
	<mcf id="6" key="1f902d54c51cf7b0374b429c7c5f6c30" />
</itemupload>

0: Ok (resumeupload)

<?xml version="1.0" encoding="utf-8"?> 
<itemupload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="desura" version="1">
	<status code="0"/>
	<mcf id="6" key="1f902d54c51cf7b0374b429c7c5f6c30">
		<complete>0</complete>
		<date>20081006180639</date>
		<member siteareaid="1"/>
		<filesize>1</filesize>
		<filesizeup>0</filesizeup>
		<filehash>hashhashhashhashhashhashhashhas1</filehash>
	</mcf>
</itemupload>

999: Finished (uploadchunk)

<?xml version="1.0" encoding="utf-8"?> 
<itemupload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="desura" version="1">
	<status code="999"/>
	<mcf id="6" key="1f902d54c51cf7b0374b429c7c5f6c30">
		<complete>1</complete>
		<date>20081006180639</date>
		<member siteareaid="1"/>
		<filesize>1</filesize>
		<filesizeup>1</filesizeup>
		<filehash>hashhashhashhashhashhashhashhas1</filehash>
	</mcf>
</itemupload>

107: Validation Error

<?xml version="1.0" encoding="utf-8"?> 
<itemupload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="desura" version="1">
	<status code="107">The filesize field is required.
The filehash field is required.
</status>
	<validation>
		<fields>
			<filesize>The filesize field is required.</filesize>
			<filehash>The filehash field is required.</filehash>
		</fields>
	</validation>
</itemupload>

110: Item Not Found

<?xml version="1.0" encoding="utf-8"?> 
<itemupload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="desura" version="1">
	<status code="110">We&#39;re sorry but you do not have permission to view the  content requested. The  requested (http://www.gamedev.com/api/itemupload) could not be found.</status>
</itemupload>

100: Generic Error

108: Permission Denied

121: Upload Started

122: Upload Failed

As above, only with different status code and text.

Post Processing

If a previous mcf exists for that item some [wiki:GeneralMCFPostProcessing] needs to happen as the file uploaded is only a patch.