Ejemplo n.º 1
0
        public Image UploadImage(UploadImageRequestBody uploadImageRequestBody, Token token)
        {
            var request = Helper.
                          GetRequestWithToken(
                BaseUrl + "/images",
                System.Net.Http.HttpMethod.Post,
                token).
                          SetRequestMultipartFormData(
                uploadImageRequestBody.ContentType,
                uploadImageRequestBody.ContentBytes);

            return(request.GetResponseJson <Image>());
        }
Ejemplo n.º 2
0
        public void UploadImage()
        {
            var client = new Medium.Client();

            var body = new UploadImageRequestBody
            {
                ContentType  = "image/gif",
                ContentBytes = System.Convert.FromBase64String("R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=")
            };

            string md5 = System.Convert.ToBase64String(
                System.Security.Cryptography.MD5.Create().ComputeHash(body.ContentBytes)).TrimEnd('=');

            var image = client.UploadImage(body, GetToken());

            Assert.NotEqual(null, image);
            Assert.NotEqual(null, image.Url);
            Assert.Equal(md5, image.Md5);
        }