public async Task <IActionResult> DownloadAsync([FromRoute(Name = "id")] string fileId) { string filePath = await GoogleDriveFilesRepositoryService.DownloadFileAsync(fileId); string fileName = Path.GetFileName(filePath); byte[] buffer = System.IO.File.ReadAllBytes(filePath); System.IO.File.Delete(filePath); return(File(buffer, "application/force-download", fileName)); }
public IActionResult Upload(IFormFile file) { string filePath = Path.Combine(Path.GetTempPath(), file.FileName); if (file.Length > 0) { using (FileStream stream = new FileStream(filePath, FileMode.Create)) { file.CopyToAsync(stream).Wait(); } } GoogleDriveFilesRepositoryService.UploadFile(filePath); return(Ok("Index")); }
public IActionResult Delete([FromRoute(Name = "id")] string fileId) { GoogleDriveFilesRepositoryService.DeleteFile(fileId); return(RedirectToAction("Index")); }
public IActionResult Index() { return(View(GoogleDriveFilesRepositoryService.GetGoogleDriveFiles())); }