【发布时间】:2016-03-22 06:42:57
【问题描述】:
我创建了一个 .Net Web API,它可以获取上传到特定 Slack 频道的文件对象/文件详细信息。
我的网址是:
"url_private":"https://files.slack.com/***.png",
"url_private_download":"https://files.slack.com/files-pri/***",
"thumb_64":"https://files.slack.com/files-tmb/***.png",
"thumb_80":"https://files.slack.com/files-tmb/****.png",
"thumb_360":"https://files.slack.com/files-tmb/***.png",
"thumb_360_w":360,
"thumb_360_h":360,
"thumb_160":"https://files.slack.com/files-tmb/***",
"image_exif_rotation":1,
"original_w":400,
"original_h":400,
"permalink":"https://laitkor.slack.com/files/*****/******/***.png",
"permalink_public":"https://slack-files.com/****"
如何从代码中下载该文件并保存在特定文件夹中。 我已经读到我们需要添加授权:Bearer A_VALID_TOKEN,我也做了同样的事情:
client.Headers["Authorization"] = "Bearer " + "********";
client.DownloadFile(new Uri("*****"),HttpContext.Current.Server.MapPath("~/Images/" + "AttachmentFile_" + (DateTime.Now.ToString("MM-dd-yy")).Replace("-", "_") + System.Guid.NewGuid().ToString() + ".jpg"));
但是这里不是下载文件,而是下载整个页面代码,当它是一个 txt 文件和损坏的文件时,它是一个图像文件。
请指导我做错了什么。
【问题讨论】: