本文整理汇总了C#中FileUpload.UploadFileAsync方法的典型用法代码示例。如果您正苦于以下问题:C# FileUpload.UploadFileAsync方法的具体用法?C# FileUpload.UploadFileAsync怎么用?C# FileUpload.UploadFileAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUpload
的用法示例。
在下文中一共展示了FileUpload.UploadFileAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadTestFileAsync
public static async Task<string> UploadTestFileAsync()
{
// Upload file
var filePath = TestFilePath;
var upload = new FileUpload("image/png", Unique.String + ".png");
return await upload.UploadFileAsync(filePath);
}
示例2: FileUploadAsyncTest
public async Task FileUploadAsyncTest()
{
var file = FileHelper.TestFilePath;
var filename = Unique.String + ".png";
Console.WriteLine("Generated file name: {0}", filename);
var handler = new FileUpload("image/png", filename);
var uploadedFilename = await handler.UploadFileAsync(file);
Console.WriteLine("Uploaded to file {0}", uploadedFilename);
}
示例3: GetDownloadUrlAsyncTest
public async Task GetDownloadUrlAsyncTest()
{
// Upload file
var filePath = FileHelper.TestFilePath;
var upload = new FileUpload("image/png", Unique.String + ".png");
var filename = await upload.UploadFileAsync(filePath);
// Get download url
var download = new FileDownload(filename);
var url = await download.GetDownloadUrl();
Assert.IsFalse(string.IsNullOrWhiteSpace(url));
Console.WriteLine("Download url: {0}", url);
}
示例4: FileUploadAsyncTest
public async Task FileUploadAsyncTest()
{
var file = FileHelper.TestFilePath;
var filename = Unique.String + ".png";
Console.WriteLine("Generated file name: {0}", filename);
var handler = new FileUpload("image/png", filename);
handler.UploadProgressChanged += (s, e) =>
{
Console.WriteLine("Uploading bytes {0} out of {1}.",
e.BytesSent, e.TotalBytesToSend);
};
handler.UploadCompleted += (s, e) =>
{
Console.WriteLine("Upload completed.");
};
var uploadedFilename = await handler.UploadFileAsync(file);
Console.WriteLine("Uploaded to file {0}", uploadedFilename);
}