tencent cloud

masukan

Single-URL Speed Limits

Terakhir diperbarui:2021-12-14 15:44:01

    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.intl.cloud.tencent.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.intl.cloud.tencent.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.

    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24