Uploads
There are three private endpoints for uploads that require a Pro account.
The example cURL calls use an example file. The example file can be downloaded here: demo.png
POST /upload
Private endpoint. Initialize the upload process and receive the id need to upload a file.
Request body
file_type: string
The type of file being uploaded. Should be one of the following values: image
original_name: string
The original name of the file, including extension: example.png
original_extension: string
The original extension of the file, including the period. Should be one of the following: .jpg, .png
upload_type: string
The purpose of the file being uploaded. Should be one of the following values: profile
total_bytes: integer
The total bytes of the file to be uploaded.
Endpoint Example
Below is a live example that can be copy and pasted.
curl -X POST https://sandbox.sellinpublic.com/api/v0/upload -u "demo:sip_api_sand_01234demo56789_key" -d "file_type=image" -d "original_name=example.png" -d "original_extension=.png" -d "upload_type=profile" -d "total_bytes=9599"
Below is the expected result from that cURL call. The `id` is the most important part of the response. The `expired_at` value tells you how much time you have to fully upload the file. Once the `expired_at` time has been reached, you will no longer be able to upload the file.
{ "status": "success", "messages": [], "meta": {}, "data": { "id": 2, "user_id": 1, "status": "created", "expired_at": "2024-03-24T07:21:04+00:00", "media": [] } }
POST /upload/{upload_id}/chunked
Private endpoint. Upload a file or part of a file.
URL params
upload_id: integer
The id of the upload (this is the id returned by the POST /upload call above).
Request body
index: integer
The number of times this endpoint has been called for this `upload_id` starting with 0. Each time a chunk is uploaded, increase the index by 1.
chunk: binary
The file data. This endpoint can be called multiple times with chunks of the file or it can be called once with the entire data.
Endpoint Example
Below is a live example that can be copy and pasted. It uses the demo.png file mentioned at the top of this page.
curl -X POST https://sandbox.sellinpublic.com/api/v0/upload/2/chunked -u "demo:sip_api_sand_01234demo56789_key" -F "index=0" -F chunk=@demo.png
Below is the expected result from that cURL call:
{ "status": "success", "messages": [], "meta": {}, "data": {} }
POST /upload/{upload_id}/completed
Private endpoint. Mark the upload as completed. The response will include the media id which can be used in other calls (like updating the profile image of an account).
URL params
upload_id: integer
The id of the upload (this is the id returned by the POST /upload call above).
Request body
total_chunks: integer
The total times the previous chunked call has been made. If it was only called once, then the `total_chunks` will be 1.
Endpoint Example
Below is a live example that can be copy and pasted.
curl -X POST https://sandbox.sellinpublic.com/api/v0/upload/2/completed -u "demo:sip_api_sand_01234demo56789_key" -d "total_chunks=1"
Below is the expected result from that cURL call:
{ "status": "success", "messages": [], "meta": {}, "data": { "id": 2, "user_id": 1, "status": "completed", "expired_at": "2024-03-24T07:21:04+00:00", "media": [ { "id": 2, "user_id": 1, "url_location": "https://sandbox.sellinpublic.com/media/100/profile_2.png", "type": "profile" } ] } }