本文整理汇总了C#中CloudinaryDotNet.Actions.ImageUploadParams类的典型用法代码示例。如果您正苦于以下问题:C# ImageUploadParams类的具体用法?C# ImageUploadParams怎么用?C# ImageUploadParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageUploadParams类属于CloudinaryDotNet.Actions命名空间,在下文中一共展示了ImageUploadParams类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestResourcesCursor
public void TestResourcesCursor()
{
// should allow listing resources with cursor
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(m_testImagePath),
PublicId = "testlistresources1"
};
m_cloudinary.Upload(uploadParams);
uploadParams = new ImageUploadParams()
{
File = new FileDescription(m_testImagePath),
PublicId = "testlistresources2"
};
m_cloudinary.Upload(uploadParams);
var listParams = new ListResourcesParams()
{
ResourceType = ResourceType.Image,
MaxResults = 1
};
var result1 = m_cloudinary.ListResources(listParams);
Assert.IsNotNull(result1.Resources);
Assert.AreEqual(1, result1.Resources.Length);
Assert.IsFalse(String.IsNullOrEmpty(result1.NextCursor));
listParams.NextCursor = result1.NextCursor;
var result2 = m_cloudinary.ListResources(listParams);
Assert.IsNotNull(result2.Resources);
Assert.AreEqual(1, result2.Resources.Length);
Assert.AreNotEqual(result1.Resources[0].PublicId, result2.Resources[0].PublicId);
}
开发者ID:Erok21,项目名称:CloudinaryDotNet,代码行数:41,代码来源:CloudinaryTest.cs
示例17: SaveUploadedFile
public ActionResult SaveUploadedFile()
{
bool isSavedSuccessfully = true;
string fName = "";
string str = "";
try
{
foreach (string fileName in Request.Files)
{
HttpPostedFileBase file = Request.Files[fileName];
//Save file content goes here
fName = file.FileName;
if (file != null && file.ContentLength > 0)
{
var originalDirectory = new DirectoryInfo(string.Format("{0}Images\\WallImages", Server.MapPath(@"\")));
string pathString = System.IO.Path.Combine(originalDirectory.ToString(), "imagepath");
var fileName1 = Path.GetFileName(file.FileName);
bool isExists = System.IO.Directory.Exists(pathString);
if (!isExists)
System.IO.Directory.CreateDirectory(pathString);
var path = string.Format("{0}\\{1}", pathString, file.FileName);
file.SaveAs(path);
Account account = new Account(
"kuzzya",
"649899148786625",
"Em9LZocDSzlf5Jf9ikhTRKwvuhY");
Cloudinary cloudinary = new Cloudinary(account);
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(path)
};
var uploadResult = cloudinary.Upload(uploadParams);
str = uploadResult.Uri.AbsoluteUri;
}
}
}
catch (Exception ex)
{
isSavedSuccessfully = false;
}
if (isSavedSuccessfully)
{
//return Json(new { Message = fName });
return Json(new { Message = "Successful", name = str });
}
else
{
return Json(new { Message = "Error in saving file" });
}
}
开发者ID:kuzzyatina95,项目名称:UchItr,代码行数:62,代码来源:HomeController.cs
示例18: UploadImage
/// <summary>
/// Uploads image on cloudinary
/// </summary>
/// <returns></returns>
private string UploadImage()
{
Account account = new Account("dvnnqotru", "252251816985341", "eqxRrtlVyiWA5-WCil_idtLzP6c");
Cloudinary cloudinary = new Cloudinary(account);
if (Request.Files.Count > 0) //is there file to upload
{
HttpPostedFileBase file = Request.Files[0];
if (file.ContentLength > 0 && _allowedTypes.Contains(file.ContentType))
{
try //test is selected file a image
{
using (var bitmap = new Bitmap(file.InputStream))
{
if (bitmap.Width < 110 || bitmap.Height < 140) //minimum size of picture is 110x140
{
ModelState.AddModelError("PictureUrl", "Picture is too small");
return null;
}
}
}
catch
{
ModelState.AddModelError("PictureUrl", "The file type is not supported");
return null;
}
file.SaveAs(Path.Combine(Server.MapPath("~/Content/"), file.FileName));
var uploadParams = new ImageUploadParams() //upload to cloudinary
{
File = new FileDescription(Path.Combine(Server.MapPath("~/Content/"), file.FileName)),
Transformation = new Transformation().Crop("fill").Width(110).Height(140)
};
var uploadResult = cloudinary.Upload(uploadParams);
System.IO.File.Delete(Path.Combine(Server.MapPath("~/Content/"), file.FileName));
return uploadResult.Uri.AbsolutePath;
}
else
{
ModelState.AddModelError("PictureUrl", "The file type is not supported");
return null;
}
}
return null;
}
开发者ID:Sholja,项目名称:bitCoupon,代码行数:52,代码来源:AvatarsController.cs
示例19: Save
public ActionResult Save(string t, string l, string h, string w, string fileName)
{
try
{
// Calculate dimensions
var top = Convert.ToInt32(t.Replace("-", "").Replace("px", ""));
var left = Convert.ToInt32(l.Replace("-", "").Replace("px", ""));
var height = Convert.ToInt32(h.Replace("-", "").Replace("px", ""));
var width = Convert.ToInt32(w.Replace("-", "").Replace("px", ""));
// Get file from temporary folder
var fn = Path.Combine(Server.MapPath(MapTempFolder), Path.GetFileName(fileName));
// ...get image and resize it, ...
var img = new WebImage(fn);
img.Resize(width, height);
// ... crop the part the user selected, ...
img.Crop(top, left, img.Height - top - AvatarStoredHeight, img.Width - left - AvatarStoredWidth);
// ... delete the temporary file,...
System.IO.File.Delete(fn);
// ... and save the new one.
var newFileName = Path.GetFileName(fn);
img.Save(Server.MapPath("~/" + newFileName));
Account account = new Account(
"lifedemotivator",
"366978761796466",
"WMYLmdaTODdm4U6VcUGhxapkcjI"
);
ImageUploadResult uploadResult = new ImageUploadResult();
CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary(account);
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(Server.MapPath("~/" + newFileName)),
PublicId = User.Identity.Name + newFileName,
};
uploadResult = cloudinary.Upload(uploadParams);
System.IO.File.Delete(Server.MapPath("~/" + newFileName));
UrlAvatar = uploadResult.Uri.ToString();
return Json(new { success = true, avatarFileLocation = UrlAvatar });
}
catch (Exception ex)
{
return Json(new { success = false, errorMessage = "Unable to upload file.\nERRORINFO: " + ex.Message });
}
}
开发者ID:irisun,项目名称:LifeDemotivator,代码行数:47,代码来源:ProfileController.cs
示例20: TestUploadLocalImage
public void TestUploadLocalImage()
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(m_testImagePath)
};
var uploadResult = m_cloudinary.Upload(uploadParams);
Assert.AreEqual(1920, uploadResult.Width);
Assert.AreEqual(1200, uploadResult.Height);
Assert.AreEqual("jpg", uploadResult.Format);
var checkParams = new SortedDictionary<string, object>();
checkParams.Add("public_id", uploadResult.PublicId);
checkParams.Add("version", uploadResult.Version);
var api = new Api(m_account);
string expectedSign = api.SignParameters(checkParams);
Assert.AreEqual(expectedSign, uploadResult.Signature);
}
开发者ID:Erok21,项目名称:CloudinaryDotNet,代码行数:22,代码来源:CloudinaryTest.cs
注:本文中的CloudinaryDotNet.Actions.ImageUploadParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论