File upload script

This script uploads a single file or group of files to Crocko servers. It uses the Crocko API. There are 3 version written in Perl, PHP and Python. They are optimized to work within a UNIX environment, but the Perl version has also been tested on Windows platforms.

Download all scripts in a single archive: crockoapi.zip (27 KB)

new All scripts can upload a single file, a whole folder or grab list of uploaded files from specific file. You can run them with -h option to see complete options list.

-h, --help            show this help message and exit
  -u USERNAME, --username=USERNAME
                        your login
  -f FILENAME, --file=FILENAME
                        path to file for upload
  -d DIRECTORY, --directory=DIRECTORY
                        path to directory with files to upload 
  -l LIST, --list=LIST
                        path to file with files list to upload (one per line)                      
  -p PASSWORD, --password=PASSWORD
                        your password
  -v                    verbose output
  -o                    output to a file. Only in compact mode. The existing file will be appended.

API for developers

Overview

This document describes the REST API for Crocko, which can be used to write applications that integrate with Crocko file hosting platform. We have provided several client libraries for Perl, PHP and Python. Currently the REST API returns responses in an XML format.

API request format: HTTP method api.crocko.com/resource

There are four basic methods in HTTP: GET, POST, PUT, and DELETE. If you can't use PUT, DELETE methods, use the POST method and add _method=PUT or _method=DELETE to the query.

Add the following string to the header of the request - Accept: application/atom+xml

All requests to the API should be made with UTF-8 encoding. Any non-ASCII character should be escaped.

Resource examples:

User authentication

Most API commands need authentication. You will need apikey for this process. Every Crocko account has its own apikey. It is used instead of a login/password combination.
You can get your apikey from the following page - http://www.crocko.com/accounts/profile/misc

An alternative way to get an apikey is to perform POST request: api.crocko.com/apikeys with params login=user_login and pass=user_password. You should store your apikey locally and use it in future API requests.

List of API methods


Description Method Parameters Needs auth Needs premium Returns
Get apikey POST /apikeys login, password no no apikey
Upload file POST /file no yes no file id, file name, file size in bytes, download link, delete link
Get file details GET /files/:id id yes yes file id, file name, file url, status
Get direct link GET /files/:id;DirectLink id yes yes file id, file url, file size
Move files into a folder PUT /folders/:id;files :id, files yes no folder id, folder url, folder size, number of moved files
Get account details GET /account :id yes no id, name, email, balance, premium, premium start, premium end
Make a file copy POST /files/copy:id :id yes no file id of copy, file name, file size in byte, copy download link, delete link

Get apikey

Request
/apikeys
HTTP-method
POST
Description
Returns apikey of account, specified by login/password pair
Parameters
Name Description
login Account login
password Account password
Returns
Name Description
content apikey
Errors
errorWrongCredentials
Examples
Curl Perl PHP Python back to the list

Upload file

Request
/file
HTTP-method
POST
Description
Upload file to crocko server
Parameters
no
Returns
Name Description
id file id
title file name
size file size in bytes
link with title download link download link
link with title delete_link delete link
Errors
errorFileSize, errorEmptyFile, errorUploadLimit, errorFileInBlackList, errorUploadFaild
Examples
Curl Perl PHP Python back to the list

Get file details

Request
/files/:id
HTTP-method
GET
Description
Get file details
Parameters
Name Description
id file id
Returns
Name Description
id file id
title file name
link with attribute length - file size file url
status (active, blocked, deleted) status
Errors
errorFileNotFound
Examples
Curl Perl PHP Python back to the list
Request
/files/:id;DirectLink
HTTP-method
GET
Description
Get direct link to the file. This link can be used to download the file. The owner of the apikey should have active Premium account. Only links to active files are returned. Blocked or deleted files do not have direct download links. To download using this link you should include apikey in the header of the HTTP request.
Parameters
Name Description
id file id
Returns
Name Description
id file id
link with attribute length - file size file url, file size
Errors
errorFileNotFound, errorPermissionDenied, errorFileInNoDownloadedStatus
Examples
Curl Perl PHP Python back to the list

Move files into a folder

Request
/folders/:id;files
HTTP-method
PUT
Description
This link can be used to move files into a folder. Link to folder and number of moved files are returned. To use this link you should include the apikey in the header of the HTTP request.
Parameters
Name Description
:id folder id
files array of file ids
Returns
Name Description
id folder id
link with attribute length folder url, folder size
ed:updated number of moved files
Errors
errorFolderNotFound, errorPermissionDenied, errorFolderFilesAddFailed
Examples
Curl Perl PHP Python back to the list

Get account details

Request
/account
HTTP-method
GET
Description
Get account and premium account details
Parameters
Name Description
:id can be found on
http://www.crocko.com/accounts/profile
Returns
Name Description
account_id id
Name of the account owner name
E-mail email
Account balance balance
Status of premium account premium
Premium account start date premium start
Premium account end date premium end
Errors
errorAccountNotFound, errorPermissionDenied
Examples
Curl Perl PHP Python back to the list

Make a file copy

Request
/files/copy:id
HTTP-method
POST
Description
This link can be used for making a file copy. A link to the file copy is returned. To use this link you should include the apikey in the header of the HTTP request.
Parameters
Name Description
:id file id
Returns
Name Description
id file id of copy
title file name
size file size in byte
link with title download_link copy download link
link with title delete_link delete link
Errors
errorFileNotFound, errorPermissionDenied
Examples
Curl Perl PHP Python back to the list

Error codes

 
Name   Comment
errorAccountNotFound   Account does not exist
errorApiKeyAlreadyCreated   ApiKey is already created
errorEmptyFile   Zero size file during upload
errorFileInBlackList   File is in black list
errorFileInNoDownloadedStatus   File is not available or deleted
errorFileNotFound   Non existing or deleted file
errorFolderNotFound   Non existing or deleted folder
errorFolderFilesAddFailed   Files wasn't added to folder
errorFileSize   File size exceeds the limit
errorPermissionDenied   No permission to run the command, for example - no active premium account
errorUploadLimit   Upload limit exceeded
errorUploadFaild   Upload failed
errorWrongCredentials   Invalid parameters were passed to API server
Choose a language: