当前位置: 首页>>代码示例>>C#>>正文


C# Actions.ImageUploadParams类代码示例

本文整理汇总了C#中CloudinaryDotNet.Actions.ImageUploadParams的典型用法代码示例。如果您正苦于以下问题:C# ImageUploadParams类的具体用法?C# ImageUploadParams怎么用?C# ImageUploadParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ImageUploadParams类属于CloudinaryDotNet.Actions命名空间,在下文中一共展示了ImageUploadParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAdHocParams

        public void TestAdHocParams()
        {
            var breakpoint = new ResponsiveBreakpoint().MaxImages(5).BytesStep(20)
                                .MinWidth(200).MaxWidth(1000).CreateDerived(false);

            ImageUploadParams uploadParams = new ImageUploadParams()
            {
                File = new FileDescription(m_testImagePath)
            };

            uploadParams.AddCustomParam("public_id", "test_ad_hoc_params_id");
            uploadParams.AddCustomParam("tags", "test");
            uploadParams.AddCustomParam("IgnoredEmptyParameter", "");
            uploadParams.AddCustomParam("responsive_breakpoints", JsonConvert.SerializeObject(new List<ResponsiveBreakpoint> { breakpoint }));
            uploadParams.AddCustomParam("IgnoredNullParameter", null);

            var paramsDict = uploadParams.ToParamsDictionary();
            Assert.AreEqual(3, paramsDict.Count);
            Assert.IsFalse(paramsDict.ContainsKey("IgnoredEmptyParameter"));
            Assert.IsFalse(paramsDict.ContainsKey("IgnoredNullParameter"));

            ImageUploadResult result = m_cloudinary.Upload(uploadParams);
            Assert.AreEqual(1, result.ResponsiveBreakpoints.Count);

            Assert.AreEqual(5, result.ResponsiveBreakpoints[0].Breakpoints.Count);
            Assert.AreEqual(1000, result.ResponsiveBreakpoints[0].Breakpoints[0].Width);
            Assert.AreEqual(200, result.ResponsiveBreakpoints[0].Breakpoints[4].Width);
        }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:28,代码来源:CloudinaryTest.cs

示例2: UploadTestResource

 /// <summary>
 /// A convenience method for uploading an image before testing
 /// </summary>
 /// <param name="id">The ID of the resource</param>
 /// <returns>The upload results</returns>
 private ImageUploadResult UploadTestResource( String id)
 {
     var uploadParams = new ImageUploadParams()
     {
         File = new FileDescription(m_testImagePath),
         PublicId = id,
         Tags = "test"
     };
     return m_cloudinary.Upload(uploadParams);
 }
开发者ID:Erok21,项目名称:CloudinaryDotNet,代码行数:15,代码来源:CloudinaryTest.cs

示例3: Store

        public string Store(string name, Stream stream)
        {
            var upload = new ImageUploadParams {
                File = new FileDescription(name, stream)
            };

            var result = cloudinary.Upload(upload);

            return string.Format("{0}.{1}", result.PublicId, result.Format);
        }
开发者ID:TallyDotNet,项目名称:event-site,代码行数:10,代码来源:IImageStorage.cs

示例4: UploadImage

 public bool UploadImage(string imgName,Stream img)
 {
     var uploadParams = new ImageUploadParams()
     {
         File = new FileDescription(imgName, img),          
         PublicId = imgName                
     };
     var uploadResult = cloudinary.Upload(uploadParams);
     //TODO: Дописать проверку на ошибку(не сохранилось ихображение)
     return true;
    
 }
开发者ID:kirill-vinnichek,项目名称:EpamTraining.Auction,代码行数:12,代码来源:CloudinaryStorage.cs

示例5: UploadImage

        public String UploadImage(String path)
        {
            var uploadParams = new ImageUploadParams()
            {
                File = new FileDescription(path),
            };

            var uploadResult = cloudinary.Upload(uploadParams);
            if (uploadResult != null)
                return uploadResult.Uri.AbsoluteUri;
            else
                return "";
        }
开发者ID:LanSilot,项目名称:Cerber-System-CSharp,代码行数:13,代码来源:CloudinaryManager.cs

示例6: CloudinaryUpload

        /// <summary>
        /// Method for uploading image from local host to cloudinary
        /// </summary>
        /// <param name="user"></param>
        /// <returns>Cloudinary link(string) of uploaded picture</returns>
        private string CloudinaryUpload(Models.RegisterBindingModel user)
        {
            var cloudPath = Server.MapPath(user.ProfileUrl);
            Account acount = new Account("gigantor", "986286566519458", "GT87e1BTMnfLut1_gXhSH0giZPg");
            Cloudinary cloudinary = new Cloudinary(acount);
            var uploadParams = new ImageUploadParams()
            {
                File = new FileDescription(cloudPath)
            };
            var uploadResult = cloudinary.Upload(uploadParams);

            string n = uploadResult.Uri.AbsoluteUri;
            return user.ProfileUrl = n;
        }
开发者ID:AdmirZirojevic,项目名称:BitCampProject,代码行数:19,代码来源:HelperController.cs

示例7: CloudinaryUpload

        /// <summary>
        /// Method for uploading image from local host to cloudinary
        /// </summary>
        /// <param name="user"></param>
        /// <returns>Cloudinary link(string) of uploaded picture</returns>
        private string CloudinaryUpload(Course course)
        {
            var cloudPath = System.Web.Hosting.HostingEnvironment.MapPath(course.PictureUrl);
            Account acount = new Account("gigantor", "986286566519458", "GT87e1BTMnfLut1_gXhSH0giZPg");
            Cloudinary cloudinary = new Cloudinary(acount);
            var uploadParams = new ImageUploadParams()
            {
                File = new FileDescription(cloudPath)
            };
            var uploadResult = cloudinary.Upload(uploadParams);

            string n = uploadResult.Uri.AbsoluteUri;
            return course.PictureUrl = n;

        }
开发者ID:AdmirZirojevic,项目名称:BitCampProject,代码行数:20,代码来源:HelperController.cs

示例8: UploadPhoto

        public string UploadPhoto(Stream stream)
        {
            Account account = new Account(
             CLOUD_NAME,
              API_KEY,
             API_SECRET);

            Cloudinary cloudinary = new Cloudinary(account);
            var uploadParams = new CloudinaryDotNet.Actions.ImageUploadParams()
            {
                File = new CloudinaryDotNet.Actions.FileDescription(Guid.NewGuid().ToString(), stream),
            };

            ImageUploadResult uploadResult = cloudinary.Upload(uploadParams);
            return cloudinary.Api.UrlImgUp.BuildUrl(String.Format("{0}.{1}", uploadResult.PublicId, uploadResult.Format));
        }
开发者ID:ezeroone,项目名称:evts,代码行数:16,代码来源:CloudinaryService.cs

示例9: uploadImage

        internal static String uploadImage(string filePath, string publicID)
        {
            //CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary();
            //CloudinaryDotNet.Account account = new CloudinaryDotNet.Account("hmtca4hsp", "551419468127826", "6CRKqZzHmHxqCvpLaObNj2Hmsis");
            CloudinaryDotNet.Account account = new CloudinaryDotNet.Account("hiisiwhue", "579971361974369", "bHspTdlzXHwF3uoLrEu5yb9a0b0");

            CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary(account);
            CloudinaryDotNet.Actions.ImageUploadParams uploadParams = new CloudinaryDotNet.Actions.ImageUploadParams()
            {
                File = new CloudinaryDotNet.Actions.FileDescription(filePath),//@"C:\Users\David\Downloads\etgarPlusWebsite-master\etgarPlusWebsite\etgarPlus\images\1.png"),
                PublicId = publicID
            };

            CloudinaryDotNet.Actions.ImageUploadResult uploadResult = cloudinary.Upload(uploadParams);

            string url = cloudinary.Api.UrlImgUp.BuildUrl(publicID + filePath.Substring(filePath.LastIndexOf(".")));
            return url;
        }
开发者ID:brahafa,项目名称:etgarPluseWeb,代码行数:18,代码来源:Global.asax.cs

示例10: uploadImage

        internal static String uploadImage(String filePath, String publicId) 
        {

            CloudinaryDotNet.Account account = new CloudinaryDotNet.Account("hmtca4hsp", "551419468127826", "6CRKqZzHmHxqCvpLaObNj2Hmsis");


            CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary(account);
            CloudinaryDotNet.Actions.ImageUploadParams uploadParams = new CloudinaryDotNet.Actions.ImageUploadParams()
            {
                File = new CloudinaryDotNet.Actions.FileDescription(filePath),//@"C:\Users\David\Downloads\etgarPlusWebsite-master\etgarPlusWebsite\etgarPlus\images\1.png"),
                PublicId = "4" //publicId
            };



            String url = cloudinary.Api.UrlImgUp.BuildUrl(publicId + filePath.Substring(filePath.LastIndexOf(".")));
            Debug.WriteLine(url);
            return url;
        }
开发者ID:yaelmo,项目名称:etgarPlusWebsite,代码行数:19,代码来源:Global.asax.cs

示例11: Save

        /// <summary>
        /// save an image to cloudinary
        /// </summary>
        /// <param name="stream">stream representing the image file to be saved</param>
        /// <param name="fileName">name of the file</param>
        /// <param name="tags">any tags to go with the image in cloudinary</param>
        /// <returns></returns>
        public ImageSaveResult Save(Stream stream, string fileName,string[] tags)
        {
            if (string.IsNullOrEmpty(fileName))
                throw new ArgumentException("fileName parameter must be initilaised");
            if(stream==null)
                throw new ArgumentException("Stream parameter cannot be null");
            
            using (stream)
            {
                stream.Seek(0, SeekOrigin.Begin); //go to the start of the stream
                //the upload params are sent to cloudinary
                var uploadParams = new ImageUploadParams {File = new FileDescription(fileName, stream)};
                //get the tags in the right format for cloudinary upload
                var tagString = ToTags(tags);
                if (!string.IsNullOrEmpty(tagString))
                    uploadParams.Tags = tagString;
                ImageUploadResult uploadResult;
                try
                {
                    uploadResult = _cloudinary.Upload(uploadParams); //upload the image and other details
                }
                catch (Exception ex)
                {
                    return new ImageSaveResult { ErrorMessage = ex.Message, Error = true };
                }
                if (uploadResult.Error != null && uploadResult.Error.Message.Length > 0)
                    return new ImageSaveResult {ErrorMessage = uploadResult.Error.Message, Error = true};

                return new ImageSaveResult
                           {
                               Error = false,
                               PublicID = uploadResult.PublicId,
                               SecureURL = _cloudinary.Api.UrlImgUp.BuildUrl(String.Format("{0}.{1}", uploadResult.PublicId, uploadResult.Format)),
                               ThumbnailURL = _cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(70).Height(70).Radius("max").Crop("thumb").Gravity("face")).BuildUrl(String.Format("{0}.{1}", uploadResult.PublicId, uploadResult.Format)),
                               URL = uploadResult.Uri.AbsoluteUri
                           };
            }

        }
开发者ID:andyevans2000,项目名称:Illuminate,代码行数:46,代码来源:ImageFactory.cs

示例12: Add

        public async Task<IEnumerable<Photo>> Add(HttpRequestMessage request)
        {
            var streamProvider = new MultipartMemoryStreamProvider();
            await request.Content.ReadAsMultipartAsync(streamProvider);
            List<Photo> photosSaved = new List<Photo>();
            foreach (HttpContent ctnt in streamProvider.Contents)
            {
                using (Stream imageStream = await ctnt.ReadAsStreamAsync())
                {
                    var uploadParams = new ImageUploadParams()
                    {
                        File = new FileDescription(ctnt.Headers.ContentDisposition.FileName, imageStream),
                        
                    };
                    ImageUploadResult uploadResult = await _cloudinary.UploadAsync(uploadParams);
                 
                    photosSaved.Add(new Photo { Uri = uploadResult.SecureUri.ToString() });
                }
            }
            return photosSaved;

        }
开发者ID:samiroquai,项目名称:Henalux,代码行数:22,代码来源:CloudinaryPhotoManager.cs

示例13: UploadImage

 /// <summary>
 /// Uploads the image.
 /// </summary>
 /// <param name="imageLink">The image link.</param>
 /// <returns></returns>
 public string UploadImage(string imageLink)
 {
     if (imageLink != null)
     {
         if (imageLink.StartsWith("http"))
         {
             return imageLink;
         }
         string pattern = "data:.*?base64,";
         string base64string = Regex.Replace(imageLink, pattern, "");
         Stream imageStream = new MemoryStream(Convert.FromBase64String(base64string));
         var uploadParams = new ImageUploadParams
         {
             File = new FileDescription("Picture", imageStream)
         };
         var uploadResult = cloud.Upload(uploadParams);
         if (uploadResult != null)
         {
             return uploadResult.Uri.AbsoluteUri;
         }
     }
     return null;
 }
开发者ID:felldek,项目名称:test,代码行数:28,代码来源:ImageService.cs

示例14: UploadComplete

        protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            try
            {
                Account account = new Account("dlyvxs7of", "634626974285569", "FtB_0jhcmFypFS7QTwCBKcPRGzE");

                Cloudinary cloudinary = new Cloudinary(account);
                ImageUploadParams uploadParams = new ImageUploadParams()
                    {
                        File = new FileDescription("file", new MemoryStream(e.GetContents()))
                    };

                ImageUploadResult uploadResult = cloudinary.Upload(uploadParams);

                HEWDataContext context = new HEWDataContext();
                context.ProjectsImages.InsertOnSubmit(new ProjectsImage
                    {ImgPublicID = uploadResult.PublicId, ProjectID = int.Parse(Request.QueryString["ProjectID"])});
                context.SubmitChanges();
            }
            catch (Exception)
            {
            }
        }
开发者ID:AdhamMowafy,项目名称:AlHuda,代码行数:23,代码来源:ProjectImages.aspx.cs

示例15: HandleFileUpload

        private string HandleFileUpload(ref Photo photo)
        {
            string filePath = @"~\Images\defaultAccomodationPhoto.jpg";

            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files[0];
                if (file.ContentLength > 0 && _allowedTypes.Contains(file.ContentType))
                {
                    try
                    {
                        using (var bitmap = new Bitmap(file.InputStream))
                        {
                        }
                    }
                    catch
                    {
                        ModelState.AddModelError("PhotoUrl", "The file type is not supported");
                        return "none";
                    }

                    string fileName = Path.GetFileName(file.FileName);
                    filePath = Path.Combine(@"~\Images\Photos", fileName);
                    string fullPath = Path.Combine(Server.MapPath(@"~\Images\Photos"), fileName);
                    file.SaveAs(fullPath);

                    Account account = new Account(
                                  "bitbooking",
                                  "131162311141994",
                                  "yqy4VSrjuxaGeP8BUMgHwTozpfw");

                    Cloudinary cloudinary = new Cloudinary(account);

                    var uploadParams = new ImageUploadParams()
                    {
                        File = new FileDescription(fullPath)
                    };
                    var uploadResult = cloudinary.Upload(uploadParams);

                    FileInfo uploadedFileToServer = new FileInfo(fullPath);
                    uploadedFileToServer.Delete();

                    return uploadResult.Uri.AbsolutePath; //new photo URL from Cloudinary
                }
                else
                {
                    if (file.ContentLength > 0 && !_allowedTypes.Contains(file.ContentType))
                    {
                        ModelState.AddModelError("PhotoUrl", "The file type is not supported");
                        return "none";
                    }

                }
            }
            //photo.PhotoUrl = filePath;
            return filePath;
        }
开发者ID:amarildos,项目名称:BitBooking,代码行数:57,代码来源:PhotosController.cs


注:本文中的CloudinaryDotNet.Actions.ImageUploadParams类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。