Exemplo n.º 1
0
        public async Task <bool> UploadPictureAsync(Models.FileModel image)
        {
            if (image.IsValid == false)
            {
                throw new ArgumentException("image is not valid", "image");
            }

            using (var dclient = this.CreateClient())
            {
                var client  = dclient.Client;
                var content = new MultipartFormDataContent();
                content.Add(new StreamContent(image.Content), "file", image.FileName);
                var response = await client.PostAsync(this.GetUri(ApiUrls.PictureUrl), content).ConfigureAwait(false);

                return(await this.HandleResponseAsync(response).ConfigureAwait(false));
            }
        }
Exemplo n.º 2
0
        public async Task<bool> UpdateDocumentThumbnailAsync(int productId, FileModel image)
        {
            if (image.IsValid == false)
                throw new ArgumentException("Invalid image parameters", "image");

            using (var dclient = this.CreateClient())
            {
                var client = dclient.Client;
                var url = ApiUrls.ThumbnailDataUrl.Replace("{id}", productId.ToString());
                var content = new MultipartFormDataContent();
                content.Add(new StreamContent(image.Content), "file", image.FileName);
                var response = await client.PostAsync(this.GetUri(url), content).ConfigureAwait(false);

                return await this.HandleResponseAsync(response).ConfigureAwait(false);
            }
        }