I've been making a program and one of the things I'm trying to do is be able to have my program take a file from its' resources and upload it to file.io. file.io is a simple file uploading website with a simple API, I'm just not sure how to use that API in my program. Once the file has been uploaded, I want to be able to get the link from the website. It's fairly simple but I'm unsure how to mimic the action of clicking the upload button and choosing my file, then grabbing the link. I know there's many posts all around about uploading files but honestly they confuse me and don't really relate to this situation. If someone knows a post that is similar to my issue and can help me, or can help me in any way I'd appreciate it a lot. If you need any details let me know.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Here ya go, their api is pretty straightforward:
using (WebClient client = new WebClient())
{
var resStr = client.UploadFile("https://file.io", @"C:\data\test.txt");
var jObjResult = JObject.Parse(Encoding.UTF8.GetString(resStr));
var linkToFile = jObjResult["link"];
}