123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using COSXML.Model;
- using COSXML.CosException;
- namespace COSXML.Transfer
- {
-
-
-
- public sealed class TransferManager
- {
- private TransferConfig transferConfig;
- private CosXml cosXml;
-
-
-
-
-
- public TransferManager(CosXml cosXmlServer, TransferConfig transferConfig)
- {
- if (cosXmlServer == null)
- {
-
- }
- if (transferConfig == null)
- {
-
- }
- this.transferConfig = transferConfig;
-
- this.cosXml = cosXmlServer;
- }
-
-
-
-
- [Obsolete("方法已废弃,请使用 UploadAsync 方法实现异步调用。")]
- public void Upload(COSXMLUploadTask uploader)
- {
- uploader.InitCosXmlServer(cosXml);
- uploader.SetDivision(transferConfig.DivisionForUpload, transferConfig.SliceSizeForUpload);
- uploader.Upload();
- }
-
-
-
-
-
- public Task<COSXMLUploadTask.UploadTaskResult> UploadAsync(COSXMLUploadTask uploader)
- {
- var task = uploader.AsyncTask<COSXMLUploadTask.UploadTaskResult>();
- Upload(uploader);
- return task;
- }
-
-
-
-
- [Obsolete("方法已废弃,请使用 DownloadAsync 方法实现异步调用。")]
- public void Download(COSXMLDownloadTask downloader)
- {
- downloader.InitCosXmlServer(cosXml);
- downloader.SetSliceSize(transferConfig.SliceSizeForDownload);
- downloader.SetDivisionSize(transferConfig.DivisionForDownload);
- downloader.Download();
- }
-
-
-
-
-
- public Task<COSXMLDownloadTask.DownloadTaskResult> DownloadAsync(COSXMLDownloadTask downloader)
- {
- var task = downloader.AsyncTask<COSXMLDownloadTask.DownloadTaskResult>();
- Download(downloader);
- return task;
- }
-
-
-
-
- [Obsolete("方法已废弃,请使用 CopyAsync 方法实现异步调用。")]
- public void Copy(COSXMLCopyTask copy)
- {
- copy.InitCosXmlServer(cosXml);
- copy.SetDivision(transferConfig.DdivisionForCopy, transferConfig.SliceSizeForCopy);
- copy.Copy();
- }
-
-
-
-
-
- public Task<COSXMLCopyTask.CopyTaskResult> CopyAsync(COSXMLCopyTask copyTask)
- {
- var task = copyTask.AsyncTask<COSXMLCopyTask.CopyTaskResult>();
- Copy(copyTask);
- return task;
- }
- }
-
-
-
- public sealed class TransferConfig
- {
-
- private long divisionForCopy = 5242880;
-
- private long sliceSizeForCopy = 2097152;
-
- private long divisionForUpload = 5242880;
-
- private long sliceSizeForUpload = 1048576;
-
- private long divisionForDownload = 20971520;
-
- private long sliceSizeForDownload = 10485760;
-
-
-
-
- public long DdivisionForCopy
- {
- get
- {
- return divisionForCopy;
- }
- set { divisionForCopy = value; }
- }
-
-
-
-
- public long DivisionForUpload
- {
- get
- {
- return divisionForUpload;
- }
- set { divisionForUpload = value; }
- }
-
-
-
-
- public long SliceSizeForCopy
- {
- get
- {
- return sliceSizeForCopy;
- }
- set { sliceSizeForCopy = value; }
- }
-
-
-
-
- public long SliceSizeForUpload
- {
- get
- {
- return sliceSizeForUpload;
- }
- set { sliceSizeForUpload = value; }
- }
-
-
-
-
- public long DivisionForDownload
- {
- get
- {
- return divisionForDownload;
- }
- set { divisionForDownload = value; }
- }
-
-
-
-
- public long SliceSizeForDownload
- {
- get
- {
- return sliceSizeForDownload;
- }
- set { sliceSizeForDownload = value; }
- }
- }
- }
|