Docs
ufile
Developer Guide
Object/File (Object)
Upload file

File Upload

Simple Upload

The term “simple upload” refers to using the PutObject method in the US3 API to upload a single file (Object). Simple upload is suitable for scenarios that can be completed with a single HTTP request interaction, such as the uploading of small files (less than 512MB).

Usage Instructions

  • For the uploading of large files( more than 512MB), please use multipart upload.

  • Naming restrictions:

  • Use UTF-8 for encoding.

  • The length must be between 1–1023 bytes.

  • It cannot begin with a forward slash (/) or a backslash(\).

  • To prevent unauthorized third parties from uploading data to your Bucket, US3 offers access control at the Bucket and Object levels.

  • Once a file is uploaded to US3, you can initiate a callback request to a specified app server through upload callback and proceed with the next step.

  • If an image is being uploaded, you can also process the image.

Form Upload

Application Scenario

Form upload is very suitable for embedding in HTML web pages to upload Objects, a common scenario is web application, take the job search website as an example:

Without Form UploadForm Upload
Process ComparisonWebsite users upload resumes.Website users upload resumes.
:::Website server responds with upload page.Website server responds with upload page.
:::Resumes are uploaded to the website server.Resumes upload to US3.
:::Website server then uploads resumes to US3.

In terms of process, using form upload eliminates one forwarding process and is more convenient. From the architectural point of view, the original upload was all through the website server. If the upload volume is too large, the website server needs to be expanded. With form upload, data is uploaded directly from the client to US3. When the upload volume is too large, the pressure is on US3, and US3 ensures the service quality.

Multipart Upload

The multipart upload (Multipart Upload) feature provided by US3 allows you to divide the file you want to upload into multiple data blocks, called Parts in US3, and upload them separately. After uploading, you can call the US3 interface to combine these Parts into an Object to achieve a breakpoint continuation effect.

Application Scenario

When using the simple upload feature (PutFile) to upload larger files to US3, if a network error occurs during the upload, the upload fails, and the retry must start from the beginning of the file. For such a situation, you can use multipart upload to achieve a breakpoint continuation effect.

Compared to other upload methods, multipart upload is applicable in the following scenarios:

  1. Poor network environment: For example, in mobile terminals, when an upload fails, individual Parts that have failed can be retried independently without having to re-upload other Parts.

  2. Speed up the upload: When the local file to be uploaded to US3 is very large, you can upload multiple Parts in parallel to speed up the upload.

  3. Streaming upload: You can start uploading when the size of the file to be uploaded is still uncertain. This scenario is more common in applications in industries such as video surveillance.

Multipart Upload Process

Split the file to be uploaded into certain size fragments.

  1. Initiate a multipart upload task.

  2. Upload the fragments one by one or in parallel.

  3. Complete the upload.

Notices

  • Except for the last Part, the size of other Parts cannot be less than 4MB, otherwise calling the FinishMultipartUpload interface will fail.

  • After dividing the file to be uploaded into Parts, the file order is determined by the partNumber specified in the upload process. There are no order requirements in actual execution, so concurrent upload can be achieved.

  • The specific number of concurrent tasks is not the more, the faster. It is necessary to consider the user’s own network conditions and equipment load.

  • By default, Parts that have been uploaded but have not yet called FinishMultipartUpload are not automatically recycled. Therefore, if you want to terminate the upload and delete the occupied space, please call AbortMultipartUpload.

Subsequent operations after upload

  • After the file is uploaded to US3, you can initiate a callback request to a designated app server through the upload callback to carry out the next step.

Upload Callback

US3 can provide a callback to the application server when the file upload is finished. You just need to carry relevant Callback parameters in the request you send to US3 to implement the callback.