Skip to content

Instantly share code, notes, and snippets.

@isdaviddong
Created December 26, 2018 15:56
Show Gist options
  • Select an option

  • Save isdaviddong/e1d1545128d94fb9e617d775588ea03c to your computer and use it in GitHub Desktop.

Select an option

Save isdaviddong/e1d1545128d94fb9e617d775588ea03c to your computer and use it in GitHub Desktop.
上傳檔案到 建立Imgur
//建立ImgurClient(其中的"CLIENT_ID", "CLIENT_SECRET"要換成你自己的)
var client = new ImgurClient(CLIENT_ID, CLIENT_SECRET);
var endpoint = new ImageEndpoint(client);
IImage image;
//取得圖片檔案FileStream
using (var fs = new FileStream(FilePath, FileMode.Open))
{
image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
}
//顯示圖檔位置
Response.Write("Image uploaded. Image Url: " + image.Link);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment