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: upload.getInfo
- Description
Obtains the information needed to perform an upload.
- Arguments
Name | Mandatory | Description |
session_key | Yes | Received from auth.login |
speed_limit | No | Upload speed limit in kilobytes, 0 for unlimited |
- 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 with the upload form
- Response
<result method="upload.getInfo" status="ok">
<upload url="" progress_url="" max_file_size="" upload_identifier="" extra_info="" />
</result>
- Usage Example
http://api.sendspace.com/rest/?method=upload.getinfo&session_key=9i96woykgory1crglmykgycjwa5k2cq2&speed_limit=0
- Possible Errors
Code | Name | Description |
6 | API_ERROR_SESSION_BAD | Session expired or not found |
11 | API_ERROR_PERMISSION_DENIED | Permission denied |
19 | API_ERROR_PRO_EXPIRED | Pro user, account expired |
20 | API_ERROR_PRO_DISKSPACE_LIMIT | Pro user, reached disk space limit |
- 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="password">
<input type="text" name="folder_id">
<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="checkbox" name="notify_uploader" value="1"> <!-- 0/1 - should the uploader be notified? -->
<input type="hidden" name="redirect_url"> <!-- page to redirect after upload will be attached upload_status=ok/fail&file_id=XXXX -->
</form>
- Different file input name
In case an application is used that hard codes the upload input field (such as Adobe Flash), it is possible to send this field name with the value of "userfile". The code will then know to read from that input, instead of "userfile".
- 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, a page with the following text will be sent:
* upload_status: ok/fail
* file_id: file_id (can be used in the API for later)
If no redirect_url is given, a page with the following text will be sent:
upload_status=ok/fail
file_id=XXXX
bandwidth_left=bytes/-1(=unlimited)
diskspace_left=bytes/-1(=unlimited)
- Progress Bar
Reading from progress_url will give the an XML output similar to this:
Because the xHTTPRequest JavaScript call, for security reasons, is unable to issue requests to hosts other than the host the page originated from, you need to make use of a simple proxy to read the progress information. For example:
<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 the xHTTPRequest JavaScript call, for security reasons, is unable to issue requests to hosts other than the host the page originated from, you need to make use of a simple proxy to read the progress information. For example:
<?
header("Content-type: text/xml");
echo file_get_contents($_REQUEST['url']);
?>
- Multiple Uploads
Multiple upload is supported by adding userfileN & descriptionN fields to the form where N is a number from 2 to 100.
* Use "userfile" & "description" without the number "1" for the first file.
Example for uploading 3 files:
* Use "userfile" & "description" without the number "1" for the first file.
Example for uploading 3 files:
<input type="file" name="userfile">
<input type="text" name="description">
<input type="file" name="userfile2">
<input type="text" name="description2">
<input type="file" name="userfile3">
<input type="text" name="description3">