TransferConfig transferConfig = new TransferConfig();// 初始化 TransferManagerTransferManager transferManager = new TransferManager(cosXml, transferConfig);// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";string cosPath = "dir/exampleObject"; // 对象键string srcPath = @"temp-source-file";//本地文件绝对路径PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, cosPath, srcPath);putObjectRequest.LimitTraffic(8 * 1024 * 1024); // 限制为1MB/sCOSXMLUploadTask uploadTask = new COSXMLUploadTask(putObjectRequest);uploadTask.SetSrcPath(srcPath);await transferManager.UploadAsync(uploadTask);
TransferConfig transferConfig = new TransferConfig();// 初始化 TransferManagerTransferManager transferManager = new TransferManager(cosXml, transferConfig);// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";string cosPath = "exampleobject"; //对象在存储桶中的位置标识符,即称对象键string localDir = System.IO.Path.GetTempPath();//本地文件夹string localFileName = "my-local-temp-file"; //指定本地保存的文件名GetObjectRequest request = new GetObjectRequest(bucket,cosPath, localDir, localFileName);request.LimitTraffic(8 * 1024 * 1024); // 限制为1MB/sCOSXMLDownloadTask downloadTask = new COSXMLDownloadTask(request);await transferManager.DownloadAsync(downloadTask);
本页内容是否解决了您的问题?