upload: Upload file

Function Description:

Upload local images, scripts, APKs, or other files to the Total Control server.
Upload files in two ways:

  • Specify the type of file to upload.
    For different types of files, you need to write the correct name.
    - image: upload the image;
    - script: upload the script file;
    - apk: upload apk file;
    - tcbr/contacts: Upload the address book file;
  • Do not specify the file type to upload.
    Need to fill in the specific location from the upload to the service.
    - local/ folder: Upload to the specified folder of the server Total Control installation root directory, for example: local/temp, upload to the temp folder, if there is no temp folder, it will be automatically created, such as Total Control installed on the computer's C drive, return "file_url" is "C:/temp/1538104935363.bmp".
    - local/<specified path:>: Upload to the path specified by the server, for example: local/E:/File/, upload to the server E:\File\ directory. The returned "file_url" is "E:/File/1539543927519.bmp".
Note: tcbr/contacts, local/folder, local/<specified path> Total Control 6.9.0 and later are available.
The file is in the directory: "%appdata%\TotalControl\v1\storage\"

Whether to support multiple devices:

No

Resource Information:

Method POST
URL .../storage
Requires authentication? Yes


Response Parameters:

A JSON string representing an array of objects with the following fields:

Field Type Description
status Boolean Return true for success and null for failure
file_url String If the value of status is true,it returns the url of the uploaded file.


Request Example:
curl http://localhost:8090/TotalControl/v1/storage?token=veLZf8EL7gUoyFOL -F "image=@d:/1.bmp"
Response Example:

If this API executes successfully, it returns:

{
    "status": true,
    "file_url": "images/1527558556026.bmp"
}


Example:

Warm tip:
Get the token needed for Total Control script development,see here.

CURL Example:

// Request: Upload image "d:/test.png"
curl http://localhost:8090/TotalControl/v1/storage?token=veLZf8EL7gUoyFOL  -F "image=@d:/test.png"
// Return:
{
    "status": true, 
    "file_url": "images/1527558556026.png"
}

Request: Upload APK "d:/QQyinle_850.apk"
curl http://localhost:8090/TotalControl/v1/storage?token=veLZf8EL7gUoyFOL  -F "apk=@d:/QQyinle_850.apk"
// Return:
{
    "status": true, 
    "file_url": "apks/1527558556026.apk"
}

// Request: Upload script "d:/getname2.js"
curl http://localhost:8090/TotalControl/v1/storage?token=veLZf8EL7gUoyFOL  -F "script=@d:/getname2.js"
// Return:
{
    "status": true, 
    "file_url": "scripts/1555735607687.js"
}

// Request: Upload the address book file 
curl http://localhost:8090/TotalControl/v1/storage?token=veLZf8EL7gUoyFOL  -F "tcbr/contacts=@E:/sigmaTC/testFile/1539448903740.json"
// Return:
{
    "status":true,
    "file_url":"tcbr/contacts/1554718175460.json"
}

// Request: Upload the image "E:\\File\\img\\image.bmp" to the specified location, which is uploaded to the temp folder of the root directory of the Total Control installation.
curl http://localhost:8090/TotalControl/v1/storage?token=veLZf8EL7gUoyFOL -F "local/temp=@E:\\File\\img\\image.bmp"
// Return:
{
    "status":true,
    "file_url":"C:/temp/1539363360758.bmp"
}

// Request: Upload the file "E:\\File\\img\\image.bmp" to the Total Control server "E:/File/"
curl http://localhost:8090/TotalControl/v1/storage?token=veLZf8EL7gUoyFOL -F "local/E:/File/=@E:\\File\\img\\image.bmp"
// Return:
{
    "status":true,
    "file_url":"E:/File/1539543927519.bmp"
}