SOAP Quick start guide
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. Or read full API description to discover how to browse user's directory for subdirectories' ids. 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!