public static async Task UploadVersion(this IPlanGridApi api, string projectUid, string versionName, params VirtualFile[] files) { VersionUpload versionUpload = await api.UploadVersion(projectUid, new UploadVersionRequest { NumberOfFiles = files.Length, VersionName = versionName }); var tasks = new List <Task>(); foreach (var item in versionUpload.FileUploadRequests.Zip(files, (x, y) => new { File = y, Request = x })) { tasks.Add(api.RequestFileUpload(item.Request, item.File)); } await Task.WhenAll(tasks); await api.CompleteVersionUpload(projectUid, versionUpload.Uid); }
public async Task UploadNewVersion() { IPlanGridApi client = PlanGridClient.Create(); await client.UploadVersion(TestData.Project2Uid, $"Version.{Guid.NewGuid()}", new VirtualFile { FileName = "Sample.pdf", Data = typeof(SheetTests).Assembly.GetManifestResourceStream("PlanGrid.Api.Tests.TestData.Sample.pdf") }); }