Zalo fo Developer - Upload hình lên zalo page qua code C# web asp.net MVC
var endpointUrl = "https://openapi.zalo.me/v2.0/store/upload/photo?access_token=" +
BasePage.SessionLogin.Zalo_Token + "&upload_type=product";
//var filePaths = new DirectoryInfo("W:\\Temp").GetFiles().Select(f => f.FullName);
using (var client = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
//foreach (String filePath in filePaths)
//{
// formData.Add(new ByteArrayContent(System.IO.File.ReadAllBytes(filePath)), Path.GetFileNameWithoutExtension(filePath), Path.GetFileName(filePath));
//}
string filePath = Path.Combine(Server.MapPath("~/Images/Products/900/"),
Path.GetFileName("0.jpg"));
formData.Add(new ByteArrayContent(System.IO.File.ReadAllBytes(filePath)), "file", Path.GetFileName(filePath));
filePath = Path.Combine(Server.MapPath("~/Images/Products/900/"),
Path.GetFileName("1.jpg"));
formData.Add(new ByteArrayContent(System.IO.File.ReadAllBytes(filePath)), "file", Path.GetFileName(filePath));
var response = client.PostAsync(endpointUrl, formData).Result;
if (response.IsSuccessStatusCode)
{
var responseData = response.Content.ReadAsStringAsync().Result;
var data = JsonConvert.DeserializeObject<Zalo_Up_img>(responseData);
Trace.Write(responseData);
}
return Json(Result);
}