tencent cloud

Feedback

Single-URL Speed Limits

Last updated: 2024-02-02 14:36:36

    Overview

    This document describes how to limit the speed on a single URL when calling the upload or download API.

    Use Instructions

    The speed range is 819200 to 838860800 (in bit/s), that is, 100 KB/s to 100 MB/s. If a value is not within this range, 400 will be returned.

    Sample 1: limiting single-URL speed on uploads

    TransferConfig transferConfig = new TransferConfig();
    
    // Initialize TransferManager.
    TransferManager transferManager = new TransferManager(cosXml, transferConfig);
    
    // Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
    string bucket = "examplebucket-1250000000";
    string cosPath = "dir/exampleObject"; // Object key
    string srcPath = @"temp-source-file";// Absolute path of the local file
    
    PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, cosPath, srcPath);
    putObjectRequest.LimitTraffic(8 * 1024 * 1024); // Limit the speed to 1 MB/s.
    
    COSXMLUploadTask uploadTask = new COSXMLUploadTask(putObjectRequest);
    
    uploadTask.SetSrcPath(srcPath);
    
    await transferManager.UploadAsync(uploadTask);
    Note:
    For the complete sample, go to GitHub.

    Sample 2: limiting single-URL speed on downloads

    TransferConfig transferConfig = new TransferConfig();
    
    // Initialize TransferManager.
    TransferManager transferManager = new TransferManager(cosXml, transferConfig);
    
    // Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
    string bucket = "examplebucket-1250000000";
    String cosPath = "exampleobject"; // Location identifier of the object in the bucket, i.e., the object key
    string localDir = System.IO.Path.GetTempPath();// Local file directory
    string localFileName = "my-local-temp-file"; // Filename of the local file
    
    GetObjectRequest request = new GetObjectRequest(bucket,
    cosPath, localDir, localFileName);
    request.LimitTraffic(8 * 1024 * 1024); // Limit the speed to 1 MB/s.
    
    COSXMLDownloadTask downloadTask = new COSXMLDownloadTask(request);
    await transferManager.DownloadAsync(downloadTask);
    Note:
    For the complete sample, go to GitHub.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support