Inheritance: IBaseSpaceClient
コード例 #1
0
 public DownloadFileCommand(BaseSpaceClient client, string fileId, Stream stream, IClientSettings settings, CancellationToken token = new CancellationToken())
 {
     _client = client;
     _settings = settings;
     _stream = stream;
     _file = _client.GetFilesInformation(new GetFileInformationRequest(fileId), null).Response;
     Token = token;
     ChunkSize = Convert.ToInt32(_settings.FileMultipartSizeThreshold);
     MaxRetries = Convert.ToInt32(_settings.RetryAttempts);
 }
コード例 #2
0
 public DownloadFileCommand(BaseSpaceClient client, FileCompact file, Stream stream, IClientSettings settings, CancellationToken token = new CancellationToken())
 {
     _client = client;
     _settings = settings;
     _stream = stream;
     _file = file;
     Token = token;
     ChunkSize = Convert.ToInt32(_settings.FileMultipartSizeThreshold);
     MaxRetries = Convert.ToInt32(_settings.RetryAttempts);
 }
コード例 #3
0
        public DownloadFileCommand(BaseSpaceClient client, FileCompact file, string targetFileName,
                                   IClientSettings settings, CancellationToken token = new CancellationToken(), bool enableLogging = true, int threadCount = DEFAULT_THREADS)
        {
            DateTime expiration;
            string   url = GetFileContentUrl(client, file.Id, out expiration);
            ILargeFileDownloadParameters parameters = new LargeFileDownloadParameters(new Uri(url), targetFileName, maxThreads: threadCount, maxChunkSize: (int?)settings.FileDownloadMultipartSizeThreshold, id: file.Id);

            _parameters    = parameters;
            _token         = token;
            _enableLogging = enableLogging;
        }
コード例 #4
0
        public DownloadFileCommand(BaseSpaceClient client, FileCompact file, string targetFileName, IClientSettings settings, int threadCount, int maxChunkSize, CancellationToken token = new CancellationToken(), bool enableLogging = true)
        {
            DateTime expiration;
            string   url = GetFileContentUrl(client, file.Id, out expiration);

            _fileName = string.Format("[{0}],{1}", file.Id, file.Name);
            ILargeFileDownloadParameters parameters = new LargeFileDownloadParameters(new Uri(url), targetFileName, maxThreads: threadCount, maxChunkSize: maxChunkSize, id: file.Id);

            _parameters    = parameters;
            _token         = token;
            _enableLogging = enableLogging;
        }
コード例 #5
0
        public DownloadFileCommand(BaseSpaceClient client, string fileId, Stream stream, IClientSettings settings, CancellationToken token = new CancellationToken(), IWebProxy proxy = null, bool enableLogging = true)
        {
            DateTime expiration;
            string   url = GetFileContentUrl(client, fileId, out expiration);

#pragma warning disable 618
            ILargeFileDownloadParameters parameters = new LargeFileDownloadWithStreamParameters(new Uri(url), stream, 0, id: fileId, maxThreads: DEFAULT_THREADS, maxChunkSize: (int)settings.FileDownloadMultipartSizeThreshold, autoCloseStream: false, verifyLength: true);
#pragma warning restore 618
            _parameters    = parameters;
            _token         = token;
            _proxy         = proxy;
            _enableLogging = enableLogging;
        }
コード例 #6
0
        private static string GetFileContentUrl(BaseSpaceClient client, string fileId, out DateTime expiration)
        {
            // get the download URL
            var response = client.GetFileContentUrl(new FileContentRedirectMetaRequest(fileId));

            if (response.Response == null || response.Response.HrefContent == null)
            {
                throw new ApplicationException("Unable to get HrefContent");
            }

            if (!response.Response.SupportsRange)
            {
                throw new ApplicationException("This file does not support range queries");
            }

            expiration = response.Response.Expires;
            return(response.Response.HrefContent);
        }
コード例 #7
0
 public DownloadFileCommand(BaseSpaceClient client, FileCompact file, Stream stream, IClientSettings settings, CancellationToken token = new CancellationToken(), IWebProxy proxy = null, bool enableLogging = true) : this(client, file.Id, stream, settings, token, proxy, enableLogging)
 {
 }