Пример #1
0
        /// <summary>
        /// create a url for file upload
        /// </summary>
        /// <param name="fileInfo"></param>
        /// <param name="metadataContainer"></param>
        /// <param name="ct"></param>
        /// <returns></returns>
        public Task <Uri> Create(FileInfo fileInfo, MetadataCollection metadataContainer = null, TusRequestOption option = default, CancellationToken ct = default)
        {
            metadataContainer ??= new MetadataCollection();
            if (!metadataContainer.ContainsKey(_tusClientOptions.FileNameMetadataName))
            {
                metadataContainer[_tusClientOptions.FileNameMetadataName] = fileInfo.Name;
            }

            return(Create(fileInfo.Length, metadataContainer, option, ct));
        }
Пример #2
0
 public static T GetOrAdd <T>(this MetadataCollection <T> collection, string key, Func <T> factory)
     where T : class, IMetadataItem
 {
     if (!collection.ContainsKey(key))
     {
         var item     = factory();
         var writable = collection.GetWritable();
         writable[key] = item;
         return(item);
     }
     return(collection[key]);
 }