Exemplo n.º 1
0
        public Stream GetFileStream(string bucketName, string key)
        {
            if (!ChunkCache.ContainsKey(GetS3Url(bucketName, key)))
            {
                S3Chunk chunk = S3ChunkStorage.GetObjectAsChunk(bucketName, key).Result;
                ChunkCache.Add(GetS3Url(bucketName, key), chunk);
                return(chunk.ResponseStream);
            }

            return(ChunkCache[GetS3Url(bucketName, key)].ResponseStream);
        }
Exemplo n.º 2
0
            private bool TryReadByte(long byteIndex, out byte b)
            {
                b = 0;

                if (byteIndex >= Session.FileInfo.FileSize)
                {
                    return(false);
                }

                // calculate chunk index by byte number
                long chunkNumber = (byteIndex / Session.FileInfo.ChunkSize) + 1;

                if (!ChunkCache.ContainsKey(chunkNumber))
                {
                    ChunkCache.Clear();
                    ChunkCache.Add(chunkNumber, Repository.Read(Session.Id, (int)chunkNumber));
                }

                // get the i-th byte inside that chunk
                b = ChunkCache[chunkNumber][byteIndex % Session.FileInfo.ChunkSize];
                return(true);
            }