public async Task <IHttpActionResult> UploadFileInFolder_SharingPermissonAsync(string folderId) { try { var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var fileName = httpRequest.Files.Keys[0]; //foreach (string fileName in httpRequest.Files.Keys) //{ var file = httpRequest.Files[fileName]; var result = await GoogleDriveFilesRepository.FileUploadInFolder(folderId, file); if (result != null) { var x = GoogleDriveFilesRepository.FileSharingPermission(result); if (x) { return(Ok(result)); } return(null); } // } return(Ok(result)); } return(InternalServerError()); } catch (Exception ex) { return(InternalServerError()); } }
public async Task <IHttpActionResult> UploadFileAsync() { try { var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var fileName = httpRequest.Files.Keys[0]; //foreach (string fileName in httpRequest.Files.Keys) //{ var file = httpRequest.Files[fileName]; var defaultFolderId = Environment.GetEnvironmentVariable("DEFAULT_FOLDER"); var result = await GoogleDriveFilesRepository.FileUploadInFolder(defaultFolderId, file); if (result != null) { var x = GoogleDriveFilesRepository.FileSharingPermission(result.ToString()); if (x) { return(Ok(result)); } return(null); } // } return(Ok(result)); } return(InternalServerError()); } catch (Exception ex) { return(InternalServerError()); } }
public void UploadFile(HttpPostedFileBase file) { String id = GoogleDriveFilesRepository.FileUploadInFolder("1ErWnUiDbV_hmEVcYYojELOje6LsNnBtP", file); if (id != null) { Response.Redirect("http://127.0.0.1:8080/songs/Create?id=" + id); } }
public void Upload(HttpPostedFileBase file) { String id = GoogleDriveFilesRepository.FileUploadInFolder("1JB5HUSkqL41QRquHHD7dzvr9tHkJxtaV", file); DateTime userLocalNow = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, System.TimeZoneInfo.Local); DateTime dateTime = DateTime.UtcNow.Date; string date = userLocalNow.ToString("dd-MM-yyyy"); Song song = new Song() { nameSong = Request["nameSong"], idSinger = int.Parse(Request["singerSong"]), idKind = int.Parse(Request["kindSong"]), urlSong = "https://drive.google.com/uc?id="+id+"&export=download", created_date = date }; imusik.Songs.Add(song); imusik.SaveChanges(); int idSong = song.idSong; if (idSong != 0) { Response.Redirect("http://192.168.137.1:8081/home/Cover/?id=" + idSong); } }
public ActionResult FileUploadInFolder(GoogleDriveFiles FolderId, HttpPostedFileBase file) { GoogleDriveFilesRepository.FileUploadInFolder(FolderId.Id, file); return(RedirectToAction("GetGoogleDriveFiles")); }