public string UploadImageTempMedia(IWeChatOAContext context, byte[] data, string filename, string mimeType) { IUploadTempMediaApi api = new UploadTempMediaApi(context); api.FileData = data; api.FileName = filename; api.ContentType = mimeType; api.Type = UploadMediaType.Image; var resp = api.Execute(); return(resp.Media_Id); }
public void TestUploadTempMediaApi() { UploadTempMediaApi api = new UploadTempMediaApi(context); api.Type = UploadMediaType.Image; api.FileName = "test.jpg"; api.ContentType = "image/jpeg"; api.ServerFilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "../../test-data/images/IMG_20150427_121714.jpg"); var response = api.Execute(); Assert.AreEqual(UploadMediaType.Image, response.Type); Assert.IsTrue(response.Created_At > 0); Assert.IsNotNull(response.Media_Id); Console.WriteLine(response.Media_Id); }