Esempio n. 1
0
        /// <summary>
        /// create a url for blobl upload
        /// </summary>
        /// <param name="blobLength"></param>
        /// <param name="metadataContainer"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <Uri> Create(long blobLength, MetadataCollection metadataContainer = null, CancellationToken cancellationToken = default)
        {
            metadataContainer ??= new MetadataCollection();
            var fingerPrint = $"{metadataContainer.Serialize()}-{blobLength}";
            var resume      = _tusClientOptions.Resume && _tusClientOptions.Store != null;

            if (resume)
            {
                var cacheUrl = _tusClientOptions.Store.Get(fingerPrint);
                if (!string.IsNullOrWhiteSpace(cacheUrl))
                {
                    return(new Uri(cacheUrl));
                }
            }
            var fileUrl = await _tusExtension.Creation(_tusClientOptions.TusHost, blobLength, metadataContainer.Serialize(), cancellationToken);

            if (fileUrl != null && resume)
            {
                _tusClientOptions.Store.Set(fingerPrint, fileUrl.ToString());
            }
            return(fileUrl);
        }
Esempio n. 2
0
        /// <summary>
        /// create a url for blob upload
        /// </summary>
        /// <param name="blobLength"></param>
        /// <param name="metadataContainer"></param>
        /// <param name="ct"></param>
        /// <returns></returns>
        public async Task <Uri> Create(long blobLength, MetadataCollection metadataContainer = null, TusRequestOption option = default, CancellationToken ct = default)
        {
            metadataContainer ??= new MetadataCollection();
            var fileUrl = await _tusExtension.Creation(_tusClientOptions.TusHost, blobLength, metadataContainer.Serialize(), option, ct);

            return(fileUrl);
        }