Skip to content

Latest commit

 

History

History
1806 lines (1405 loc) · 35.3 KB

File metadata and controls

1806 lines (1405 loc) · 35.3 KB

#TFS RESTful API

NOTE: bold words are fixed and reserved for API, italics words are input arguments.

##Raw TFS

###WRITE

####Description

The implementation of WRITE operation stores data as a TFS file. File name is returned in JSON format.

####Syntax

POST /v1/appkey HTTP/1.1

Host: 10.0.0.1:7500

Content-Length: length

Date: date

appkey is an id of an application configured in RcServer database. If you are not using RcServer, use tfs as appkey.

####Request Parameters

parameter description
suffix file suffix
simple_name whether require the right suffix to access the file
1: require the right suffix to access
0: no such restrict
large_file whether save as large file(file name will start with 'L')
1: save as large file
0: do not save as large file

####Response

name description
TFS_FILE_NAME TFS file name returned

####Status code

HTTP status code description
200 OK operation success
400 Bad Request bad request
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey to write a TFS file without suffix:

POST /v1/tfs HTTP/1.1
Host: 10.0.0.1:7500
Content-Length: 22
Date: Fri, 30 Nov 2012 03:05:00 GMT

[data]

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Fri, 30 Nov 2012 03:05:00 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

{
	"TFS_FILE_NAME": "T1FOZHB4ET1RCvBVdK"
}

The following request will use tfs as appkey to write a TFS file with ".jpg" as its suffix. Access with this suffix is required.

POST /v1/tfs?suffix=.jpg&simple_name=1 HTTP/1.1
Host: 10.0.0.1:7500
Content-Length: 22
Date: Fri, 30 Nov 2012 03:05:00 GMT

[data]

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Fri, 30 Nov 2012 03:05:00 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

{
	"TFS_FILE_NAME": "T1FOZHB4ET1RCvBVdK.jpg"
}

###UPDATE

####Description

The implementation of UPDATE updates a existing TFS file. Also a TFS file name will returned in JSON format.

####Syntax

PUT /v1/appkey/TfsFileName HTTP/1.1

Host: 10.0.0.1:7500

Content-Length: length

Date: date

appkey is an id of an application configured in RcServer database. If you are not using RcServer, use tfs as appkey.

####Request Parameters

parameter description
suffix file suffix
simple_name whether require the right suffix to access the file
1: require the right suffix to access
0: no such restrict

####Response

name description
TFS_FILE_NAME TFS file name returned

####Status code

HTTP status code description
200 OK operation success
400 Bad Request bad request
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey to update the TFS file T1FOZHB4ET1RCvBVdK:

PUT /v1/tfs/T1FOZHB4ET1RCvBVdK HTTP/1.1
Host: 10.0.0.1:7500
Content-Length: 22
Date: Fri, 30 Nov 2012 03:05:00 GMT

[data]

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Fri, 30 Nov 2012 03:05:00 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

{
	"TFS_FILE_NAME": "T1FOZHB4ET1RCvBVdK"
}

###READ

####Description

The implementation of READ reads data from a TFS file.

####Syntax

GET /v1/appkey/TfsFileName HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database. If you are not using RcServer, use tfs as appkey.

####Request Parameters

parameter description
suffix file suffix
NOTE: If this parameter is given, and there is another different suffix in TfsFileName, then the access will fail.
offset offset to read in the file
size size to read

####Response

name description
data data readed

####Status code

HTTP status code description
200 OK operation success
400 Bad Request bad request
404 Not Found file not found
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey to read file T1FOZHB4ET1RCvBVdK:

GET /v1/tfs/T1FOZHB4ET1RCvBVdK HTTP/1.1
Host: 10.0.0.1:7500
Date: Fri, 30 Nov 2012 03:05:00 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Fri, 30 Nov 2012 03:05:00 GMT
Last-Modified: Thu, 29 Nov 2012 03:05:00 GMT
Transfer-Encoding: chunked
Connection: keep-alive

[data]

The following request will use tfs as appkey to read file T1FOZHB4ET1RCvBVdK.jpg:

GET /v1/tfs/T1FOZHB4ET1RCvBVdK.jpg HTTP/1.1
Host: 10.0.0.1:7500
Date: Fri, 30 Nov 2012 03:05:00 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Fri, 30 Nov 2012 03:05:00 GMT
Last-Modified: Thu, 29 Nov 2012 03:05:00 GMT
Transfer-Encoding: chunked
Connection: keep-alive

[data]

###DELETE

####Description

The implementation of DELETE deletes or conceal a TFS file.

####Syntax

DELETE /v1/appkey/TfsFileName HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database. If you are not using RcServer, use tfs as appkey.

####Request Parameters

parameter description
suffix file suffix
NOTE: If this parameter is given, and there is another different suffix in TfsFileName, then the access will fail.
hide specify the operation of conceal:
1: conceal
0: reveal

####Response

No

####Status code

HTTP status code description
200 OK operation success
400 Bad Request bad request
404 Not Found file not found
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey to delete file T1FOZHB4ET1RCvBVdK:

DELETE /v1/tfs/T1FOZHB4ET1RCvBVdK HTTP/1.1
Host: 10.0.0.1:7500
Date: Fri, 30 Nov 2012 03:05:00 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Fri, 30 Nov 2012 03:05:00 GMT
Content-Length: 0
Connection: keep-alive

The following request will use tfs as appkey to conceal file T1FOZHB4ET1RCvBVdK.jpg:

DELETE /v1/tfs/T1FOZHB4ET1RCvBVdK.jpg?hide=1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Fri, 30 Nov 2012 03:05:00 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Fri, 30 Nov 2012 03:05:00 GMT
Content-Length: 0
Connection: keep-alive

###STAT

####Description

The implementation of STAT achieve the meta data of a TFS file. The meta data will be returned in JSON format.

####Syntax

GET /v1/appkey/metadata/TfsFileName HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database. If you are not using RcServer, use tfs as appkey.

####Request Parameters

parameter description
suffix file suffix
NOTE: If this parameter is given, and there is another different suffix in TfsFileName, then the access will fail.
type achieve type:
0: normal, will fail if file is deleted or concealed.
1: force, will success even if file is deleted or concealed.

####Response

name description
FILE_NAME file name
BLOCK_ID id of the block that contains this file
FILE_ID file id
OFFSET file offset inside the block
SIZE file size
OCCUPY_SIZE occupy size of file
MODIFY_TIME modify time
CREATE_TIME create time
STATUS status of file
0: normal
1: deleted
4: concealed
5: concealed and deleted
CRC crc of file data

####Status code

HTTP status code description
200 OK operation success
400 Bad Request bad request
404 Not Found file not found
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey to stat file T1FOZHB4ET1RCvBVdK:

GET /v1/tfs/metadata/T1FOZHB4ET1RCvBVdK HTTP/1.1
Host: 10.0.0.1:7500
Date: Fri, 30 Nov 2012 03:05:00 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Fri, 30 Nov 2012 03:05:00 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

{
    "FILE_NAME": "T1FOZHB4ET1RCvBVdK",
    "BLOCK_ID": 101,
    "FILE_ID": 9223190836479524436,
    "OFFSET": 69563585,
    "SIZE": 103578,
    "OCCUPY_SIZE": 103614,
    "MODIFY_TIME": "Fri, 09 Mar 2012 13:40:32 UTC+0800",
    "CREATE_TIME": "Fri, 09 Mar 2012 13:40:32 UTC+0800",
    "STATUS": 0,
    "CRC": 3208008078
}

##Custom TFS

###GET_APPID

####Description

The implementation of GET_APPID gets appid of the specified TFS application. Appid is returned in JSON format. Each application can get a unique appid corresponding to its appkdy. This appid is a required paramter in each Custom TFS operation. You can consider this as a namespace in TFS.

####Syntax

GET /v2/appkey/appid HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

####Request Parameters

No

####Response

name description
APP_ID appid of application

####Status code

HTTP status code description
200 OK operation success
400 Bad Request bad request
500 Internal Server Error login failed(maybe this appkey is not configured in RcServer database) or internal server error in tfs or nginx server

####Examples

The following request will query the appid of appkey tfs:

GET /v2/tfs/appid HTTP/1.1
Host: 10.0.0.1:7500
Date: Thu, 28 Jun 2012 08:00:26 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Thu, 28 Jun 2012 08:00:26 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

{
    "APP_ID": "1"
}

###CREATE_DIR

####Description

The implementation of CREATE_DIR creates a dir.

####Syntax

POST /v2/appkey/appid/uid/dir/dir_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

parameter description
recursive 1: recursively create parent dirs
0: do not recursively create parent dirs

####Response

No

####Status code

HTTP status code description
201 Created operation success
400 Bad Request invalid dir name
401 Unauthorized do not have permission(each application is only allowed to modify its namespace(under its appid))
403 Forbidden subdir count/subfile count/dir depth exceeds the restrict
409 Conflict dir already exists
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, create "/dir_1" under the namespace of appid 1 and uid 1234:

POST /v2/tfs/1/1234/dir/dir_1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Fri, 30 Nov 2012 03:05:00 GMT

The corresponding response will be:

HTTP/1.1 201 Created
Server: Tengine/1.3.0
Date: Wed, 27 Jun 2012 14:59:27 GMT
Content-Length: 0
Connection: keep-alive

###RM_DIR

####Description

The implementation of RM_DIR removes a dir.

####Syntax

DELETE /v2/appkey/appid/uid/dir/dir_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

No

####Response

No

####Status code

HTTP status code description
200 Ok operation success
400 Bad Request invalid dir name
401 Unauthorized do not have permission(each application is only allowed to modify its namespace(under its appid))
403 Forbidden dir is not empty
404 Not Found dir or parent dir not exist
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs appkey, remove "/dir_1" under the namespace of appid 1 uid 1234:

DELETE /v2/tfs/1/1234/dir/dir_1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Thu, 28 Jun 2012 08:12:13 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Thu, 28 Jun 2012 08:12:13 GMT
Content-Length: 0
Connection: keep-alive

###MV_DIR

####Description

The implementation of MV_DIR moves or renames a dir.

####Syntax

POST /v2/appkey/appid/uid/dir/dest_dir_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

x-ali-move-source: /src_dir_name

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

A custom HTTP request header is needed here to specify the src dir.

####Request Parameters

parameter description
recursive 1: recursively create parent dirs of the dest dir
0: do not recursively create parent dirs of the dest dir

####Response

No

####Status code

HTTP status code description
200 Ok operation success
400 Bad Request invalid dir name
401 Unauthorized do not have permission(each application is only allowed to modify its namespace(under its appid))
403 Forbidden move to subdir
404 Not Found src dir or parent dir not exist, or dest dir already exists, or parent dir of dest dir not exist
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, rename "/dir_src" as "/dir_dest" under the namespace of appid 1 uid 1234:

POST /v2/tfs/1/1234/dir/dir_dest HTTP/1.1
Host: 10.0.0.1:7500
Date: Sat, 30 Jun 2012 05:33:05 GMT
x-ali-move-source: /dir_src

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Sat, 30 Jun 2012 05:33:05 GMT
Content-Length: 0
Connection: keep-alive

###LS_DIR

####Description

The implementation of LS_DIR lists all subdirs and subfiles. Subdirs and subfiles are returned in JSON format.

####Syntax

GET /v2/appkey/metadata/appid/uid/dir/dir_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

No

####Response

name description
NAME file/dir name/td>
PID if of the parent dir of file/dir
ID if of file/dir
SIZE file size
IS_FILE is file or not
CREATE_TIME create time
MODIFY_TIME modify time/td>
VER_NO version no of file/dir

####Status code

HTTP status code description
200 Ok operation success
400 Bad Request invalid dir name
404 Not Found dir or parent dir not exist
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, list all subdirs and subfiles of the dir "/" under the namespace of appid 1 and uid 1234:

GET /v2/tfs/metadata/1/1234/dir/ HTTP/1.1
Host: 10.0.0.1:7500
Date: Sat, 30 Jun 2012 05:42:25 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Sat, 30 Jun 2012 05:42:25 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

[
    {
        "NAME": "d_0",
        "PID": 635213,
        "ID": 635218,
        "SIZE": 0,
        "IS_FILE": false,
        "CREATE_TIME": "Wed, 27 Jun 2012 10:32:04 UTC+0800",
        "MODIFY_TIME": "Wed, 27 Jun 2012 11:29:30 UTC+0800",
        "VER_NO": 0
    },
    {
        "NAME": "d_3",
        "PID": 635213,
        "ID": 635219,
        "SIZE": 0,
        "IS_FILE": false,
        "CREATE_TIME": "Wed, 27 Jun 2012 10:36:17 UTC+0800",
        "MODIFY_TIME": "Sat, 30 Jun 2012 13:32:53 UTC+0800",
        "VER_NO": 0
    },
    {
        "NAME": "file_1",
        "PID": -9223372036854140595,
        "ID": 0,
        "SIZE": 222,
        "IS_FILE": true,
        "CREATE_TIME": "Wed, 27 Jun 2012 17:13:23 UTC+0800",
        "MODIFY_TIME": "Wed, 27 Jun 2012 17:25:03 UTC+0800",
        "VER_NO": 1
    }
]

###IS_DIR_EXIST

####Description

The implementation of IS_DIR_EXIST checks if the specified dir exists.

####Syntax

HEAD /v2/appkey/appid/uid/dir/dir_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

No

####Response

No

####Status code

HTTP status code description
200 Ok dir exists
400 Bad Request invalid dir name
404 Not Found dir not exist
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, check whether dir "/dir_1" exists under the namespace of appid 1 uid 1234:

HEAD /v2/tfs/1/1234/dir/dir_1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Sat, 30 Jun 2012 05:42:25 GMT

If dir exists, the corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Sat, 30 Jun 2012 05:42:25 GMT
Content-Length: 0
Connection: keep-alive

###CREATE_FILE

####Description

The implementation of CREATE_FILE creates a file.

####Syntax

POST /v2/appkey/appid/uid/file/file_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

parameter description
recursive 1: recursively create parent dirs
0: do not recursively create parent dirs

####Response

No

####Status code

HTTP status code description
201 Created operation success
400 Bad Request invalid file name
401 Unauthorized do not have permission(each application is only allowed to modify its namespace(under its appid))
403 Forbidden subdir count/subfile count/dir depth exceeds the restrict
404 Not Found parent dir not exist
409 Conflict file already exists
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, create "/file_1" under the namespace of appid 1 uid 1234:

POST /v2/tfs/1/1234/file/file_1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Fri, 30 Nov 2012 03:05:00 GMT

The corresponding response will be:

HTTP/1.1 201 Created
Server: Tengine/1.3.0
Date: Wed, 27 Jun 2012 14:59:27 GMT
Content-Length: 0
Connection: keep-alive

###WRITE_FILE

####Description

The implementation of WRITE_FILE write data to a file. PWRITE is supported. File hole is also supported. Append is used by default.

NOTE: in-place update is not supported.

####Syntax

PUT /v2/appkey/appid/uid/file/file_name HTTP/1.1

Host: 10.0.0.1:7500

Content-Length: length

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

parameter description
offset offset to write
size data size to write

####Response

No

####Status code

HTTP status code description
200 Ok operation success
400 Bad Request invalid file name or parameter
401 Unauthorized do not have permission(each application is only allowed to modify its namespace(under its appid))
404 Not Found file not found
409 Conflict data already exists in write offset(in-place update)
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, write data to "/file_1" under the namespace of appid 1 uid 1234:

PUT /v2/tfs/1/1234/file/file_1 HTTP/1.1
Host: 10.0.0.1:7500
Content-Length: 222
Date: Wed, 27 Jun 2012 14:59:27 GMT

[Data]

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Wed, 27 Jun 2012 14:59:27 GMT
Content-Length: 0
Connection: keep-alive

###READ_FILE

####Description

The implementation of READ_FILE reads data from a file.

####Syntax

GET /v2/appkey/appid/uid/file/file_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

parameter description
offset offset to read
size data size to read

####Response

name description
data data readed

####Status code

HTTP status code description
200 Ok operation success
400 Bad Request invalid file name or parameter
404 Not Found file not found
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, read data from "/file_1"(whole file) under the namespace of appid 1 uid 1234:

GET /v2/tfs/1/1234/file/file_1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Wed, 27 Jun 2012 14:59:27 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Wed, 27 Jun 2012 14:59:27 GMT
Content-Length: 222
Connection: keep-alive

[data]

###RM_FILE

####Description

The implementation of RM_FILE removes a file.

####Syntax

DELETE /v2/appkey/appid/uid/file/file_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

No

####Response

No

####Status code

HTTP status code description
200 Ok operation success
400 Bad Request invalid file name
401 Unauthorized do not have permission(each application is only allowed to modify its namespace(under its appid))
404 Not Found file not found
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, remove "/file_1" under the namespace of appid 1 uid 1234:

DELETE /v2/tfs/1/1234/file/file_1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Thu, 28 Jun 2012 08:12:13 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Thu, 28 Jun 2012 08:12:13 GMT
Content-Length: 0
Connection: keep-alive

###MV_FILE

####Description

The implementation of MV_FILE move or rename a file.

####Syntax

POST /v2/appkey/appid/uid/file/dest_file_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

x-ali-move-source: /src_file_name

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

A custom HTTP request header is needed here to specify the src file.

####Request Parameters

parameter description
recursive 1: recursively create parent dirs of the dest file
0: do not recursively create parent dirs of the dest file

####Response

No

####Status code

HTTP status code description
200 Ok operation success
400 Bad Request invalid file name or src file and dest file are the same file
401 Unauthorized do not have permission(each application is only allowed to modify its namespace(under its appid))
404 Not Found src file not exist, or dest file already exists, or parent dir of dest file not exist
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, rename "/file_src" to "/file_dest" under the namespace of appid 1 uid 1234:

POST /v2/tfs/1/1234/file/file_dest HTTP/1.1
Host: 10.0.0.1:7500
Date: Sat, 30 Jun 2012 05:33:05 GMT
x-ali-move-source: /file_src

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Sat, 30 Jun 2012 05:33:05 GMT
Content-Length: 0
Connection: keep-alive

###LS_FILE

####Description

The implementation of LS_FILE achieves the meta data of the file.

####Syntax

GET /v2/appkey/metadata/appid/uid/file/file_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

No

####Response

name description
NAME file name(absolute path)
PID id of the parent dir of the file
ID id of the file
SIZE file size
IS_FILE is file or not
CREATE_TIME create time
MODIFY_TIME modify time
VER_NO version no of file

####Status code

HTTP status code description
200 Ok operation success
400 Bad Request invalid file name
404 Not Found file not found
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, achieve the meta data of "/file_1" under the namespace of appid 1 uid 1234:

GET /v2/tfs/metadata/1/1234/file/file_1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Sat, 30 Jun 2012 05:42:25 GMT

The corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Sat, 30 Jun 2012 05:42:25 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

{
    "NAME": "/file_1",
    "PID": 635213,
    "ID": 0,
    "SIZE": 298481,
    "IS_FILE": true,
    "CREATE_TIME": "Fri, 15 Jun 2012 09:37:39 UTC+0800",
    "MODIFY_TIME": "Sat, 30 Jun 2012 23:57:38 UTC+0800",
    "VER_NO": 0
}

###IS_FILE_EXIST

####Description

The implementation of IS_FILE_EXIST checks if file exists.

####Syntax

HEAD /v2/appkey/appid/uid/file/file_name HTTP/1.1

Host: 10.0.0.1:7500

Date: date

appkey is an id of an application configured in RcServer database.

Appid can be achieved by the API GET_APPID.

Uid is short for user id, each appid and uid makes a unique namespace in TFS.

####Request Parameters

No

####Response

No

####Status code

HTTP status code description
200 Ok file exist
400 Bad Request invalid file name
404 Not Found file not found
500 Internal Server Error internal server error in tfs or nginx server

####Examples

The following request will use tfs as appkey, check if "/file_1" exists under the namespace of appid 1 uid 1234:

HEAD /v2/tfs/1/1234/file/file_1 HTTP/1.1
Host: 10.0.0.1:7500
Date: Sat, 30 Jun 2012 05:42:25 GMT

If file exists, the corresponding response will be:

HTTP/1.1 200 OK
Server: Tengine/1.3.0
Date: Sat, 30 Jun 2012 05:42:25 GMT
Content-Length: 0
Connection: keep-alive