Esempio n. 1
0
        public async Task <HttpResponseMessage> DownloadFile(string fileId)
        {
            var dataAccess = new FileDataAccess();
            var blobAccess = new BlobAccess.BlobAccess();

            var fileEntity = await dataAccess.GetFileAsync(fileId);

            var file = await blobAccess.DownloadFileAsync(fileEntity.RowKey.ToLowerInvariant());

            return(file);
        }
Esempio n. 2
0
        public async Task <string> UploadFile(HttpPostedFile file)
        {
            var dataAccess    = new FileDataAccess();
            var blobAccess    = new BlobAccess.BlobAccess();
            var fileName      = file.FileName;
            var contetnLength = file.ContentLength;
            var fileId        = Guid.NewGuid().ToString();

            try
            {
                var writeResult = await dataAccess.WriteFileAsync(new FileEntity(fileName, fileId, contetnLength.ToString()));

                await blobAccess.UploadFileAsync(file);

                return(writeResult);
            }
            catch (StorageException exception)
            {
                throw new Exception(exception.Message);
            }
        }