Example #1
0
        public async Task 指定されたパスがファイルの場合ファイルが取得できること()
        {
            var entry = await sut.GetEntryAsync("path1/Blob1.txt");

            Assert.IsNotNull(entry);
            Assert.IsTrue(entry is Blob);
        }
Example #2
0
        public async Task <IActionResult> Index(string path)
        {
            var entry = await _blobs.GetEntryAsync(path).ConfigureAwait(false);

            if (entry == null)
            {
                return(Redirect(Url.ViewFile(new DocumentPath(path).Parent?.Value)));
            }
            ViewData["Path"] = entry.Path;
            return(View(entry));
        }
Example #3
0
        public async Task <IActionResult> Get(
            [FromQuery] string path   = "",
            [FromQuery] bool download = false)
        {
            var entry = await _queries.GetEntryAsync(path ?? "").ConfigureAwait(false);

            if (entry == null)
            {
                return(NotFound());
            }
            if (download && entry is Blob blob)
            {
                if (Request.Headers.Keys.Contains("If-None-Match") && Request.Headers["If-None-Match"].ToString() == "\"" + blob.Hash + "\"")
                {
                    return(new StatusCodeResult(304));
                }

                var data = await _storage.FindAsync(blob.StorageKey ?? blob.Path).ConfigureAwait(false);

                if (data == null)
                {
                    return(new StatusCodeResult((int)HttpStatusCode.InternalServerError));
                }
                return(File(await data.OpenStreamAsync().ConfigureAwait(false), blob.ContentType, blob.Name, new DateTimeOffset(blob.LastModified), new EntityTagHeaderValue("\"" + blob.Hash + "\"")));
            }
            else
            {
                return(Ok(entry));
            }
        }