github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/obs/client_resume.go (about)

     1  // Copyright 2019 Huawei Technologies Co.,Ltd.
     2  // Licensed under the Apache License, Version 2.0 (the "License"); you may not use
     3  // this file except in compliance with the License.  You may obtain a copy of the
     4  // License at
     5  //
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software distributed
     9  // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    10  // CONDITIONS OF ANY KIND, either express or implied.  See the License for the
    11  // specific language governing permissions and limitations under the License.
    12  
    13  package obs
    14  
    15  // UploadFile resume uploads.
    16  //
    17  // This API is an encapsulated and enhanced version of multipart upload, and aims to eliminate large file
    18  // upload failures caused by poor network conditions and program breakdowns.
    19  func (obsClient ObsClient) UploadFile(input *UploadFileInput, extensions ...extensionOptions) (output *CompleteMultipartUploadOutput, err error) {
    20  	if input.EnableCheckpoint && input.CheckpointFile == "" {
    21  		input.CheckpointFile = input.UploadFile + ".uploadfile_record"
    22  	}
    23  
    24  	if input.TaskNum <= 0 {
    25  		input.TaskNum = 1
    26  	}
    27  	if input.PartSize < MIN_PART_SIZE {
    28  		input.PartSize = MIN_PART_SIZE
    29  	} else if input.PartSize > MAX_PART_SIZE {
    30  		input.PartSize = MAX_PART_SIZE
    31  	}
    32  
    33  	output, err = obsClient.resumeUpload(input, extensions)
    34  	return
    35  }
    36  
    37  // DownloadFile resume downloads.
    38  //
    39  // This API is an encapsulated and enhanced version of partial download, and aims to eliminate large file
    40  // download failures caused by poor network conditions and program breakdowns.
    41  func (obsClient ObsClient) DownloadFile(input *DownloadFileInput, extensions ...extensionOptions) (output *GetObjectMetadataOutput, err error) {
    42  	if input.DownloadFile == "" {
    43  		input.DownloadFile = input.Key
    44  	}
    45  
    46  	if input.EnableCheckpoint && input.CheckpointFile == "" {
    47  		input.CheckpointFile = input.DownloadFile + ".downloadfile_record"
    48  	}
    49  
    50  	if input.TaskNum <= 0 {
    51  		input.TaskNum = 1
    52  	}
    53  	if input.PartSize <= 0 {
    54  		input.PartSize = DEFAULT_PART_SIZE
    55  	}
    56  
    57  	output, err = obsClient.resumeDownload(input, extensions)
    58  	return
    59  }