sendspace API (1.2)

> Upload New File

Developer Guide

The sendspace Application Programming Interface (API) allows you to embed sendspace services in your applications, programs, or scripts, regardless of platform and programming language.
All communication with the sendspace API (1.2) assumes a UTF-8 encoding.

< Return to Method List

Method: anonymous.uploadGetInfo

Description

Obtains the basic information needed to make an anonymous upload. This method does not require authentication or login.

Arguments
Name Mandatory Description
speed_limit No Upload speed limit in kilobytes, 0 for unlimited
api_key Yes Received from sendspace
api_version Yes 1.0
app_version No Application specific, formatting / style is up to you
Returns

URL to upload the file to, progress_url for real-time progress information, max_file_size for max size current user can upload, upload_identifier & extra_info to be passed in the upload form

Response

<result method="anonymous.uploadgetinfo" status="ok">
    <upload url="" progress_url="" max_file_size="" upload_identifier="" extra_info="" />
</result>
                
Possible Errors
Code Name Description
5 API_ERROR_BAD_API_VERSION Unknown or unsupported API version
upload method

<form method="post" action="[url value received in response]" enctype="multipart/form-data">
    <!-- MUST FIELDS -->
    <input type="hidden" name="MAX_FILE_SIZE" value="[max_file_size value received in response]">
    <input type="hidden" name="UPLOAD_IDENTIFIER" value="[upload_identifier value received in response]">
    <input type="hidden" name="extra_info" value="[extra_info value received in response]">
    <input type="file" name="userfile">

    <!-- OPTIONAL FIELDS --->
    <input type="text" name="description">
    <input type="text" name="recipient_email">  <!-- an email (or emails separated with ,) of recipient/s to receive information about the upload -->
    <input type="text" name="recipient_message">  <!-- a message to include in email to recipient/s -->
    <input type="text" name="notify_uploader" value="">  <!-- uploader email -->
    <input type="hidden" name="redirect_url">  <!-- page to redirect after upload will be attached upload_status=ok/fail&file_id=XXXX -->
</form>
                    
When Upload Ends
If redirect_url was given, it will redirect to the URL, also adding two extra URL params to it:
* upload_status: ok/fail
* file_id: file_id (can be used in the API for later)
If no redirect_url is given, an xml page with following format will be sent:

<upload_done>
    <status>ok</status>
    <download_url>http://www.sendspace.com/file/XXXXX</download_url>
    <delete_url>http://www.sendspace.com/delete/XXXXX/YYYY</delete_url>
    <file_id>XXXXX</file_id>
</upload_done>

Progress Bar
Reading from progress_url can give the following XML result:

<progress>
    <status>ok/fail/done</status>
    <eta>00:00:00</eta>
    <speed>50</speed> <!-- in kbps -->
    <uploaded_bytes>1000</uploaded_bytes> <!-- in bytes -->
    <total_size>50000</total_size> <!-- in bytes -->
    <elapsed>00:00:00</elapsed>
    <meter>0-100</meter> <!-- percentage of upload done -->
</progress>


Because Ajax, for security reasons, is unable to issue requests to hosts other than the host the pages originated from, you need to make use a proxy to read the progress information. For example:

<?
header("Content-type: text/xml");
echo file_get_contents($_REQUEST['url']);
?>

Title

Alert