Пример #1
0
        async private Task UploadImage(IFormFile headerImage, PageContentTypes pageContentType, string id, string url)
        {
            string uiUrl = UIUrl;

            using (var httpClient = new HttpClient())
            {
                try
                {
                    var content = new MultipartFormDataContent();

                    content.Add(headerImage.ToStreamContent(), "file", url);

                    var result = await httpClient.PostAsync(
                        new Uri(string.Format("{0}/api/JSON/UploadImage/{1}/{2}/{3}",
                                              uiUrl,
                                              (int)pageContentType,
                                              id,
                                              url)),
                        content);
                }
                catch (Exception ex)
                {
                }
            }
        }
Пример #2
0
        public JsonResult UploadImage(IFormFile file, PageContentTypes type, string itemid, string filename)
        {
            filename = Path.GetFileNameWithoutExtension(filename);
            var upload = new FormUpload(_environment.WebRootPath); if (file != null)

            {
                switch (type)
                {
                case PageContentTypes.Campaign:
                    upload.SaveFile(file, filename, "campaign");
                    break;

                case PageContentTypes.Category:
                    upload.SaveFile(file, filename, "categoryheader");
                    break;
                }
            }

            return(Json("OK"));
        }