有可能让
以下是目前的情况:
CloudBlockBlob.UploadFromStreamAsync
接受图片URL吗?
我想使用LinkedIn basicprofile api来检索用户的图片URL(已获取URL),并尝试下载和上传该图片到Azure Blob,就像他们从计算机中选择了一张图片。以下是目前的情况:
using (Html.BeginForm("UploadPhoto", "Manage", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div class="browseimg">
<input type="file" class="display-none" name="file" id="files" onchange="this.form.submit()" />
</div>
}
<button class="btn btn-primary width-100p main-bg round-border-bot" id="falseFiles">
Upload billede
</button>
控制器中的方法:
public async Task<ActionResult> UploadPhoto(HttpPostedFileBase file)
{
if (file != null && file.ContentLength > 0)
{
var fileExt = Path.GetExtension(file.FileName);
if (fileExt.ToLower().EndsWith(".png")
|| fileExt.ToLower().EndsWith(".jpg")
|| fileExt.ToLower().EndsWith(".gif"))
{
var user = await GetCurrentUserAsync()
await service.Upload(user.Id, file.InputStream);
}
}
return RedirectToAction("Index")
}