Skip to content

Instantly share code, notes, and snippets.

@donma
Created March 5, 2025 05:03
Show Gist options
  • Save donma/60f738552274db3b9a7f436bfaf98493 to your computer and use it in GitHub Desktop.
Save donma/60f738552274db3b9a7f436bfaf98493 to your computer and use it in GitHub Desktop.
var filePath = AppDomain.CurrentDomain.BaseDirectory + "oig.jpg";
//user key from https://vgy.me/account/details
var response=UploadImageVgyMe(filePath, "user_key");
Console.WriteLine("Image path:" + response.image);
static VgyMeUploadImageResponse UploadImageVgyMe(string filePath, string userKey)
{
var client = new RestClient("https://vgy.me/upload");
var request = new RestRequest("", Method.Post);
request.AddFile("file", filePath, "image/jpeg"); // 根據實際檔案類型調整 MIME 類型
request.AddParameter("userkey", userKey);
var response = client.Execute(request);
Console.WriteLine(response.Content); // 印出 API 回應
return JsonConvert.DeserializeObject<VgyMeUploadImageResponse>(response.Content);
}
public class VgyMeUploadImageResponse
{
public bool error { get; set; }
public int size { get; set; }
public string filename { get; set; }
public string ext { get; set; }
public string url { get; set; }
public string image { get; set; }
public string delete { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment