2 min read
This API generates a pre-signed URL for file uploads, allowing files to be uploaded directly to the specified location. Please note that the URL is time-sensitive and will expire after 5 minutes.
POST https://usapi.hottask.com/chat/User/GetPreUploadUrl
The API request must include the following headers:
Authorization: <Your-Secret-Key>
Content-Type: application/json
The request body should contain the following parameters:
{ // fileName(string, required): The filename. EG: companyinfo.txt "fileName":"companyinfo.txt" }
const res = await fetch('https://usapi.hottask.com/chat/User/GetPreUploadUrl', { method: 'POST', headers: { 'Authorization': `<Your-Secret-Key>`, 'Content-Type': 'application/json', }, body: JSON.stringify({ fileName: '<Your filename>', }),});const data = await res.json();console.log(data);
import requestsimport jsonurl = 'https://usapi.hottask.com/chat/User/GetPreUploadUrl'headers = { 'Authorization': '<Your-Secret-Key>', 'Content-Type': 'application/json'}data = { 'fileName': '<Your filename>'}response = requests.post(url, headers=headers, data=json.dumps(data))data = response.json()print(data)
curl https://usapi.hottask.com/chat/User/GetPreUploadUrl \ -H 'Content-Type: application/json' \ -H 'Authorization: <Your-Secret-Key>' \ -d '{"fileName": "your filename"}'
POST /chat/User/GetPreUploadUrl HTTP/1.1Host: usapi.hottask.comAuthorization: <Your-Secret-Key>Content-Type: application/json{ "fileName": "<Your filename>"}
The API response will be a JSON object with the following structure:
{ "Data": { "FileStoreId":"34317", "PreUploadUrl":"https://xxx.s3.us-west-1.amazonaws.com/xxx/3706/627855d5-ba01-4732-9dfd-b08a72744c77.txt?X-Amz-Expires=600\u0026X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=AKIA5TS7CBKE4ZSWBI46%2F20250121%2Fus-west-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20250121T030214Z\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=a237335d9b2e6fad1c648f753d393906647db5528eaaecf5e55dd114a22653db", }, "Version": "1.0.0", "Success": true, "Code": 200, "Message":""}
If it’s an HTTP network error, you should check the HTTP status code. If it’s a business exception, you need to examine the Code and Message fields, which will provide the error details.
HTTP status code
Code
Message
That’s it! You should now be able to create a chatbot using the create API.
This API allows the user to mark the file as successfully uploaded.
POST https://usapi.hottask.com/chat/User/ReportUploadSuccess
{ // fileStoreID(string, required): The file id. "fileStoreID":"123"}
const res = await fetch('https://usapi.hottask.com/chat/User/ReportUploadSuccess', { method: 'POST', headers: { 'Authorization': `<Your-Secret-Key>`, 'Content-Type': 'application/json', }, body: JSON.stringify({ fileStoreID: '123' }),});const data = await res.json();console.log(data);
import requestsimport jsonurl = 'https://usapi.hottask.com/chat/User/ReportUploadSuccess'headers = { 'Authorization': '<Your-Secret-Key>', 'Content-Type': 'application/json'}data = { 'fileStoreID': '123'}response = requests.post(url, headers=headers, data=json.dumps(data))data = response.json()print(data)
curl https://usapi.hottask.com/chat/User/ReportUploadSuccess \ -H 'Content-Type: application/json' \ -H 'Authorization: <Your-Secret-Key>' \ -d '{"fileStoreID": "123"}'
POST /chat/User/ReportUploadSuccess HTTP/1.1Host: usapi.hottask.comAuthorization: <Your-Secret-Key>Content-Type: application/json{ "fileStoreID": "123"}
{ "Data": true, "Version": "1.0.0", "Success": true, "Code": 200, "Message":""}
That’s it! You should now be able to upload a file using these two APIs.
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Post Comment