Difference between revisions of "SOAP Quick start guide"

From 4shared wiki
Jump to: navigation, search
(New page: First of all you should discover if you have enough free space is in user’s account: function long getFreeSpace(String login, String password); (returned value – free space in bytes) ...)
 
Line 1: Line 1:
 
 
First of all you should discover if you have enough free space is in user’s account:
 
First of all you should discover if you have enough free space is in user’s account:
function long getFreeSpace(String login, String password);
+
  function long getFreeSpace(String login, String password);
 
(returned value – free space in bytes)
 
(returned value – free space in bytes)
  
 
And how much user can upload in one file:
 
And how much user can upload in one file:
function long getMaxFileSize(String login, String password);
+
  function long getMaxFileSize(String login, String password);
 
(returned value – maximally permissible file size in bytes)
 
(returned value – maximally permissible file size in bytes)
  
Line 11: Line 10:
  
 
Get session:
 
Get session:
function String createUploadSessionKey(String login, String password, long dirID);
+
  function String createUploadSessionKey(String login, String password, long dirID);
 
Set ‘-1’ as DirId parameter. In this case file will be uploaded to the root directory. Return session key if all is ok and empty or null string if you can't upload to specified dir.
 
Set ‘-1’ as DirId parameter. In this case file will be uploaded to the root directory. Return session key if all is ok and empty or null string if you can't upload to specified dir.
  
 
Get datacenter:
 
Get datacenter:
function int getNewFileDataCenter(String login, String password);
+
  function int getNewFileDataCenter(String login, String password);
 +
If returned datacenter is less or equal then 0 - something goes wrong.
  
 
Then get URL for upload using session and datacenter:
 
Then get URL for upload using session and datacenter:
function String getUploadFormUrl(int dataCenterID, String sessionKey);
+
  function String getUploadFormUrl(int dataCenterID, String sessionKey);
 
Returned string is valid only if starts from http in other cases you can't upload file;
 
Returned string is valid only if starts from http in other cases you can't upload file;
  
 
To reserve fileId for yor upload call function:
 
To reserve fileId for yor upload call function:
function long uploadStartFile(String login, String password, long dirID, String name, long fullSize);
+
  function long uploadStartFile(String login, String password, long dirID, String name, long fullSize);
 +
Again fileId can be only positive.
  
 
Then use received URL and fileId to upload by executing POST query multipart/form-data with fields
 
Then use received URL and fileId to upload by executing POST query multipart/form-data with fields
 +
 
1) resumableFileId (file ID received via previous method)
 
1) resumableFileId (file ID received via previous method)
 +
 
2) resumableFirstByte (index of the first byte of current piece. If a file is uploaded as single unit – then pass 0. If the file is separated on pieces and is uploaded by pieces – then pass index of the byte, from which every piece starts)
 
2) resumableFirstByte (index of the first byte of current piece. If a file is uploaded as single unit – then pass 0. If the file is separated on pieces and is uploaded by pieces – then pass index of the byte, from which every piece starts)
  
Line 31: Line 34:
  
 
When all pieces are uploaded call function:
 
When all pieces are uploaded call function:
function String uploadFinishFile(String login, String password, long fileId, String md5);
+
  function String uploadFinishFile(String login, String password, long fileId, String md5);
 
where last parameter is file’s md5 digest. If the file is successfully uploaded – function returns null or empty line, if not – text of error. If the file was uploaded by pieces, this function unites them into one.
 
where last parameter is file’s md5 digest. If the file is successfully uploaded – function returns null or empty line, if not – text of error. If the file was uploaded by pieces, this function unites them into one.
  
 
You are done!
 
You are done!

Revision as of 10:44, 17 June 2010

First of all you should discover if you have enough free space is in user’s account:

 function long getFreeSpace(String login, String password);

(returned value – free space in bytes)

And how much user can upload in one file:

 function long getMaxFileSize(String login, String password);

(returned value – maximally permissible file size in bytes)

Please, check if target file corresponds to the mentioned conditions, if it does then:

Get session:

 function String createUploadSessionKey(String login, String password, long dirID);

Set ‘-1’ as DirId parameter. In this case file will be uploaded to the root directory. Return session key if all is ok and empty or null string if you can't upload to specified dir.

Get datacenter:

 function int getNewFileDataCenter(String login, String password);

If returned datacenter is less or equal then 0 - something goes wrong.

Then get URL for upload using session and datacenter:

 function String getUploadFormUrl(int dataCenterID, String sessionKey);

Returned string is valid only if starts from http in other cases you can't upload file;

To reserve fileId for yor upload call function:

 function long uploadStartFile(String login, String password, long dirID, String name, long fullSize);

Again fileId can be only positive.

Then use received URL and fileId to upload by executing POST query multipart/form-data with fields

1) resumableFileId (file ID received via previous method)

2) resumableFirstByte (index of the first byte of current piece. If a file is uploaded as single unit – then pass 0. If the file is separated on pieces and is uploaded by pieces – then pass index of the byte, from which every piece starts)

Attach the file to the query as a parameter FilePart.

When all pieces are uploaded call function:

 function String uploadFinishFile(String login, String password, long fileId, String md5);

where last parameter is file’s md5 digest. If the file is successfully uploaded – function returns null or empty line, if not – text of error. If the file was uploaded by pieces, this function unites them into one.

You are done!