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()); } }