How to upload all files in folder to Google Storage Cloud without loop. Here I try use C# with one file upload :
public async Task<ActionResult> Upload(IFormFile file)
{
string contentRootPath = _hostingEnvironment.ContentRootPath;
var credential = GoogleCredential.FromJson(System.IO.File.ReadAllText(contentRootPath + "/credentials.json"));
StorageClient storageClient = StorageClient.Create(credential);
var objectName = MakeObjectName();
var imageObject = await storageClient.UploadObjectAsync(
bucket: CloudConfig.BUCKET,
objectName: objectName,
contentType: file.ContentType,
source: file.OpenReadStream(),
options: new UploadObjectOptions { PredefinedAcl = PredefinedObjectAcl.PublicRead }
);
return Ok(new DropzoneInfo { Name = file.FileName, ObjectName = objectName, Link = imageObject.MediaLink, Size = file.Length});
}