This is version . It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]

CrushFTP supports REST style operations for file transfer. All you need is an auth header with BASIC auth, or a logged in cookie token. If issuing a POST command, and using the CrushAuth cookie, you must also specify the c2f parameter. The c2f is the last 4 characters of the CrushAuth cookie.

The base URL on all of these is simply http://domain.com/

LOGIN
#

You can get the CrushAuth cookie token via a POST with these parameters:
command=login&username=user&password=pass&encoded=true

Alternatively just issuing the HTTP BASIC auth header with its normal BASE64 encoded syntax is also valid but can't be tracked to a single session. So its not always desirable even though its convenient.

DOWNLOAD/UPLOAD
#

For file transfer, you can now do a GET or PUT command to download or upload.

GET /myfiles/file1.txt HTTP/1.1
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
PUT /anotherfolder/file2.txt HTTP/1.1
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
The path is for the user's VFS as configured in the User Manager. It has nothing to do with your server's local filesystem.

RENAME
#

A rename can be done via the MOVE HTTP command, or via a POST with more parameters:
MOVE /myfiles/file1.txt HTTP/1.1
Location: http://serverdomain.com/anotherfolder/file3.txt
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
Or POST:
command=rename&path=/myfiles/&name1=file1.txt&name2=/anotherfolder/file3.txt&c2f=ABCD
  • This is the same command issued via our WebInterface, so you can always inspect with Chrome for other commands on how we do it.


MAKEDIR
#

A make directory can be done via the MKCOL HTTP command, or via a POST with more parameters:
MKCOL /myfiles2/ HTTP/1.1
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
Or POST:
command=makedir&path=/myfiles2/&c2f=ABCD
  • This is the same command issued via our WebInterface, so you can always inspect with Chrome for other commands on how we do it.


DELETE
#

Deleting can be done via DELETE HTTP command or via POST with more parameters:
DELETE /myfiles/file1.txt HTTP/1.1
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
Or POST:
command=delete&names=/anotherfolder/file3.txt&c2f=ABCD


LIST
#

Directory listings have no REST command, so POST must be used:
command=getXMLListing&path=/anotherfolder/&format=stat_dmz&c2f=ABCD

  • Format can be one of these types:json,jsonobj,stat,stat_dmz. stat_dmz is the most commonly used format type. It contains some summary info about the current directory's permissions followed by the listing for that directory.


STAT
#

Getting info about a single file can be done with HTTP HEAD, or more info from STAT:
HEAD /myfolder/file1.txt HTTP/1.1
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
Or POST:
command=stat&path=/anotherfolder/file1.txt&format=stat_dmz&c2f=ABCD

  • Format can be one of these types:json,jsonobj,stat,stat_dmz. stat_dmz is the most commonly used format type. It contains some summary info about the current directory's permissions followed by the listing for that directory.


UPLOAD MultiPart
#

Multipart form uploading is also possible, but far more complex of a topic. You should already be familiar with how multipart works. The parameters for uploading as below. The email related stuff is only needed if the sendEmail header is true. See also the example curl call at the end of this page, some headers can be left out.
command=STOR
alt_name=file4.txt
uploadPath=/anotherfolder/
start_resume_loc=0. ***OPTIONAL
Last-Modified=milliseocndtimestamp ***OPTIONAL
c2f=ABCD
filenameobjectdata

SHARE
#

Share a file or folder. The parameters for sharing are:
command: publish
allowUploads: false
attach: true
hide_download: false
attach_real: false
baseUrl: http%253A%252F%252Fdc1.intranet.local%253A8080%252F
emailBcc: 
emailReplyTo: 
emailBody: %253Cp%253EA%2520user%2520would%2520like%2520to%2520share%2520a%2520file%2520with%2520you.%2526nbsp%253B%253C%252Fp%253E%253Cp%253EThis%2520link%2520will%2520expire%2520on%2520%257Bdate%257D%2520at%2520%257Btime%257D%2520https%253A%252F%252Fyourdomian.com%252F%257Bweb_link_end%257D%253C%252Fp%253E%253Cp%253E%253Cbr%253E%253C%252Fp%253E
share_comments: 
emailCc: 
emailFrom: admin%40intranet.local
emailSubject: Sharing%253A%2520A%2520new%2520file%2520is%2520being%2520shared%2520with%2520you.
emailTo: test%40intranet.local
shareUsername: false
shareUsernames: 
shareUsernamePermissions: (resume)(view)(slideshow)
expire: 7%2F3%2F2021+23%3A59
paths: %252Ftestfile1.txt
publishType: reference
logins: -1
sendEmail: true
direct_link: true


LOGOUT
#

A logged in session with a CrushAuth cookie can be logged out so anything pending the logout will be triggered.
command=logout&c2f=ABCD

EXAMPLES
#


Upload a file:
curl -T KB2.txt -u user:pass http://127.0.0.1:8080/KB2.txt
Download:
curl -u user:pass http://127.0.0.1:8080/KB2.txt -o KB2.txt
Delete:
curl --data "command=delete&names=/KB2.txt" -u user:pass http://127.0.0.1:8080/
Rename:
curl --data "command=rename&path=/&name1=KB2.txt&name2=/KB3.txt" -u user:pass http://127.0.0.1:8080/
MakeDir:
curl --data "command=makedir&path=/myfiles2/" -u user:pass http://127.0.0.1:8080/
List:
curl --data "command=getXMLListing&path=/&format=jsonobj" -u user:pass http://127.0.0.1:8080/

Add new attachment

Only authorized users are allowed to upload new attachments.
« This particular version was published on 04-Jun-2021 05:58 by Ada Csaba.
G’day (anonymous guest)
CrushFTP10 | What's New

Referenced by
API

JSPWiki