Resumable Upload
API Description
This API is an encapsulated and enhanced version of multipart upload, and aims to eliminate large file upload failures caused by poor network conditions and program breakdowns.
Method Definition
func (obsClient ObsClient) UploadFile(input *UploadFileInput) (output *CompleteMultipartUploadOutput, err error)
Request Parameters
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Mandatory |
Returned Results
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() {
input := &obs.UploadFileInput{}
input.Bucket = "bucketname"
input.Key = "objectname"
input.UploadFile = "localfile" // Path of the local file to be uploaded. The file name must be specified.
input.EnableCheckpoint = true // Enable the resumable upload mode.
input.PartSize = 9 * 1024 * 1024 // Set the part size to 9 MB.
input.TaskNum = 5 // Specify the maximum number of parts that can be concurrently uploaded.
output, err := obsClient.UploadFile(input)
if err == nil {
fmt.Printf("RequestId:%s\n", output.RequestId)
fmt.Printf("ETag:%s\n", output.ETag)
} else if obsError, ok := err.(obs.ObsError); ok {
fmt.Printf("Code:%s\n", obsError.Code)
fmt.Printf("Message:%s\n", obsError.Message)
}
} Last Article: Creating a Signed URL
Next Article: Resumable Download
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.