示例#1
0
        public byte[] Download(IArchiveType archiveType, params string[] ids)
        {
            var r = _innerClient.Download(new DownloadRequest
            {
                Format = new Archiver {
                    Format = archiveType.Format, Type = archiveType.Type
                },
                Ids = GrpcExtensions.IdSetFromIds(ids)
            });
            var list = r.ResponseStream.ToListAsync().Result;

            return(list.SelectMany(x => x.Data.ToByteArray()).ToArray());
        }
示例#2
0
        public Dictionary <string, StatusResult> Upload(IArchiveType archiveType, IEnumerable <byte> bytes)
        {
            var stream = _innerClient.Upload();
            var chunks = bytes
                         .Batch(1024 * 1024)
                         .Select(x => x.ToArray());

            stream.RequestStream.WriteAllAsync(
                chunks.Select(x => new Chunk
            {
                Data   = ByteString.CopyFrom(x),
                Format = new Archiver {
                    Format = archiveType.Format, Type = archiveType.Type
                }
            })
                ).Wait();
            return(stream.ResponseAsync.Result.Entry.ToDictionary());
        }
示例#3
0
		public void AddArchiveType(IArchiveType type)
		{
			types.Add(type);

			foreach (string ext in type.GetExtensions())
				extMap[ext] = type;
		}
示例#4
0
 public void AddType(IArchiveType type)
 {
     types_.Add(type.Identifier, type);
 }