// callback that handles retrieving a list of models on AWS. void ListModelsHandler(AmazonServiceResult <ListObjectsRequest, ListObjectsResponse> cb) { if (cb.Exception != null) { Debug.Log(cb.Exception); } string latestKey = ""; ListObjectsResponse resp = cb.Response; foreach (S3Object obj in resp.S3Objects) { latestKey = obj.Key; } // retrieve latest model and store it. Debug.Log("Importing model named " + latestKey); _client.GetObject(AWSClient.BUCKET_NAME, latestKey, GetModelObjectHandler); }
public ActionResult DownloadFile(int fileId) { var userData = _readOnlyRepository.First <Account>(a => a.EMail == User.Identity.Name); var fileData = userData.Files.FirstOrDefault(f => f.Id == fileId); var objectRequest = new GetObjectRequest { BucketName = userData.BucketName, Key = fileData.Url + fileData.Name, Timeout = int.MaxValue, ReadWriteTimeout = int.MaxValue }; var file = AWSClient.GetObject(objectRequest); var byteArray = new byte[file.ContentLength]; file.ResponseStream.Read(byteArray, 0, (int)file.ContentLength); //var template_file = System.IO.File.ReadAllBytes(); return(new FileContentResult(byteArray, fileData.Type) { FileDownloadName = fileData.Name }); }
public ActionResult DownloadAudio(long id) { var userData = _readOnlyRepository.First <Account>(a => a.EMail == User.Identity.Name); var fileData = userData.Files.FirstOrDefault(f => f.Id == id); var objectRequest = new GetObjectRequest { BucketName = userData.BucketName, Key = fileData.Url + fileData.Name }; var file = AWSClient.GetObject(objectRequest); var byteArray = new byte[file.ContentLength]; file.ResponseStream.Read(byteArray, 0, (int)file.ContentLength); //var template_file = System.IO.File.ReadAllBytes(); return(File(byteArray, "audio/mp3")); // Assuming that the resume is an MS Word document... // return File(t.FileStream, fileData.Type); }