Upload Files

Posted Jan 10 2022 13:50:58 in API

To upload files via your command line or within your application, we suggest using CURL:

Guest uploads

1. First, create a session to obtain an "fuid" which will be used to identify further requests for a specific upload.

  
$ curl 'https://up.ufile.io/v1/upload/create_session' \
-d 'file_size=TOTAL_SIZE_OF_FILE'
  

On success, you will receive the "fuid" in a JSON response such as:

  {"fuid":"857f63d5a91512b55e38270b12ae78e2"}

2. Copy the "fuid" and post it with each chunk of your file, until the entire file has been uploaded:

  
curl 'https://up.ufile.io/v1/upload/chunk' \
-F 'chunk_index=CURRENT_CHUNK_NUMBER' \
-F 'fuid=FUID_FROM_SESSION_REQUEST' \
-F 'file=@LOCATION_OF_CHUNK_TO_UPLOAD'
  

3. Once all chunks have been uploaded, you can finalise the upload like this:

  
curl 'https://up.ufile.io/v1/upload/finalise' \
-d 'fuid=FUID_FROM_SESSION_REQUEST' \
-d 'file_name=YOUR_FILENAME' \
-d 'file_type=YOUR_EXTENSION' \
-d 'total_chunks=TOTAL_CHUNK_COUNT'
  

For example:

  
curl 'https://up.ufile.io/v1/upload/finalise' \
-d 'fuid=7b40c3f085481e8fb4feb2a7c914905b' \
-d 'file_name=Screenshot 2021-07-09 at 15.47.05.png' \
-d 'file_type=png' \
-d 'total_chunks=1'
  

On success, you will receive confirmation like this:

  
   {
      "status":true,
      "id":1620449,
      "url":"https:\/\/ufile.io\/ewty4gfl",
      "destination":"https:\/\/ufile.io\/ewty4gfl",
      "name":"g48b2w9m-manta-3.mp4",
      "filename":"ewty4gfl-g48b2w9m-manta-3.mp4",
      "slug":"ewty4gfl",
      "size":"32.2 MB",
      "type":"video",
      "expiry":"∞",
      "location":10
    }
  

User uploads with api_key

To upload permanent files to your account you'll need an api_key, which is available on our Business plan, and can be found here

First, create a session to obtain an "fuid" which will be used to identify further requests for a specific upload.

  
$ curl 'https://up.ufile.io/v1/upload/create_session' \
-H "X-API-KEY: YOUR_API_KEY" \
-d 'file_size=TOTAL_SIZE_OF_FILE'
  

Then repeat steps 2 & 3 from above in "Guest uploads"

More recent stories

Jan 10 2022 13:50:58
How do I cancel my subscription?
Read More
Jan 10 2022 13:50:58
How secure is Uploadfiles?
Read More

Ready to go Pro?

Signup today and unlock all our features