RavenGallery.Core.Infrastructure.RavenFileStorageService.RetrieveFile C# (CSharp) Method

RetrieveFile() public method

public RetrieveFile ( string filename ) : byte[]
filename string
return byte[]
        public byte[] RetrieveFile(string filename)
        {
            var file = documentStore.DatabaseCommands.GetAttachment(filename);
            return file != null ? file.Data : null;
        }

Usage Example

コード例 #1
0
        public void WhenRetrieveFileInvokedWithValidArguments_AttachmentIsReturnedFromRaven()
        {
            Byte[] fileBytes = new Byte[] { 3, 1, 4, 1, 5, 9 };
            String filename = "images/mySuperDuperFile";

            this.Store.DatabaseCommands.PutAttachment(filename, null, fileBytes, new Newtonsoft.Json.Linq.JObject());

            RavenFileStorageService storage = new RavenFileStorageService(this.Store);
            var retrievedAttachment = storage.RetrieveFile(filename);
            Assert.AreEqual(fileBytes, retrievedAttachment);
        }