public async Task <ActionResult> Index(string contentItemId)
        {
            var part = await _fileService.GetFilePart(contentItemId);

            if (part == null)
            {
                return(NotFound());
            }
            var fileInfo = await _formFileStore.GetFileInfoAsync(part.FullPath.Text);

            return(new FileStreamResult(await _formFileStore.GetFileStreamAsync(fileInfo), part.MimeType()));
        }
Ejemplo n.º 2
0
        // NEXT STATION: Services/CustomFileStore.cs

        public async Task <string> CreateFileInCustomFolder()
        {
            // Now it will be the same process as it was with the IMediaFileStore but it will be our ICustomFileStore
            // this time. The files will be created inside our CustomFiles folder as it was defined in Startup.cs.
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes("Hi there in the custom file storage!")))
            {
                await _customFileStore.CreateFileFromStreamAsync(TestFileRelativePath, stream, true);
            }

            var fileInfo = await _customFileStore.GetFileInfoAsync(TestFileRelativePath);

            return($"Successfully created file in the custom file storage! File size: {fileInfo.Length} bytes.");
        }