public void TestListResourcesByTag() { // should allow listing resources by tag FileDescription file = new FileDescription(m_testImagePath); ImageUploadParams uploadParams = new ImageUploadParams() { File = file, Tags = "teslistresourcesbytag1,beauty" }; m_cloudinary.Upload(uploadParams); uploadParams = new ImageUploadParams() { File = file, Tags = "teslistresourcesbytag1" }; m_cloudinary.Upload(uploadParams); ListResourcesResult result = m_cloudinary.ListResourcesByTag("teslistresourcesbytag1", null); Assert.AreEqual(2, result.Resources.Count()); }
public async Task <ListResourcesResult> ListResourcesAsync(ListResourcesParams parameters) { var url = Api.ApiUrlV.ResourceType("resources").Add(Api.GetCloudinaryParam(parameters.ResourceType)); if (parameters is ListResourcesByTagParams) { var resourcesByTagParams = (ListResourcesByTagParams)parameters; if (!string.IsNullOrEmpty(resourcesByTagParams.Tag)) { url.Add("tags").Add(resourcesByTagParams.Tag); } } if (parameters is ListResourcesByModerationParams) { var moderationParams = (ListResourcesByModerationParams)parameters; if (!string.IsNullOrEmpty(moderationParams.ModerationKind)) { url.Add("moderations").Add(moderationParams.ModerationKind).Add(Api.GetCloudinaryParam(moderationParams.ModerationStatus)); } } using (var response = await Api.CallAsync(HttpMethod.Get, new UrlBuilder(url.BuildUrl(), parameters.ToParamsDictionary()).ToString(), null, null, null)) { return(await ListResourcesResult.Parse(response)); } }
public void TestListResources() { // should allow listing resources ListResourcesResult resources = m_cloudinary.ListResources(); Assert.NotNull(resources); }
public void TestListResources() { // should allow listing resources ListResourcesResult resources = m_cloudinary.ListResources(); Assert.NotNull(resources); Assert.NotZero(resources.Resources.Length, resources.Error?.Message); }
public void TestListResources() { // should allow listing resources ListResourcesResult resources = m_cloudinary.ListResources(); Assert.NotNull(resources); Assert.NotZero(resources.Resources.Length); Assert.NotNull(resources.Resources[0].AccessMode); }
protected IEnumerable <Resource> GetAllResults(Func <String, ListResourcesResult> list) { ListResourcesResult current = list(null); IEnumerable <Resource> resources = current.Resources; for (; resources != null && current.NextCursor != null; current = list(current.NextCursor)) { resources = resources.Concat(current.Resources); } return(resources); }
public void TestListResourcesByPrefix() { // should allow listing resources by prefix ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription(m_testImagePath), PublicId = "testlistblablabla" }; m_cloudinary.Upload(uploadParams); ListResourcesResult result = m_cloudinary.ListResourcesByPrefix("upload", "testlist", null); Assert.IsTrue(result.Resources.Where(res => res.PublicId.StartsWith("testlist")).Count() == result.Resources.Count()); }
public void TestListResourcesByType() { // should allow listing resources by type ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription(m_testImagePath), PublicId = "testlistresourcesbytype" }; m_cloudinary.Upload(uploadParams); ListResourcesResult result = m_cloudinary.ListResourcesByType("upload", null); Assert.IsTrue(result.Resources.Where(res => res.PublicId == uploadParams.PublicId && res.Type == "upload").Count() > 0); }
// Test disabled because it deletes all images in the remote account. public void DeleteAllInLoop() { return; string nextCursor = String.Empty; while (true) { ListResourcesResult existingResources = String.IsNullOrEmpty(nextCursor) ? m_cloudinary.ListResources() : m_cloudinary.ListResources(nextCursor); nextCursor = existingResources.NextCursor; DelResParams deleteParams = new DelResParams(); bool resourcesLeft = false; foreach (var res in existingResources.Resources) { if (res.Type != "sprite") { deleteParams.Type = res.Type; resourcesLeft = true; break; } } if (!resourcesLeft) { break; } foreach (var resource in existingResources.Resources) { if (resource.Type == deleteParams.Type) { deleteParams.PublicIds.Add(resource.PublicId); } } Console.WriteLine("Deleting {0} resources of type {1}...", deleteParams.PublicIds.Count, deleteParams.Type); m_cloudinary.DeleteResources(deleteParams); } }
public void TestResourcesCursor() { // should allow listing resources with cursor ImageUploadParams 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); ListResourcesParams listParams = new ListResourcesParams() { ResourceType = ResourceType.Image, MaxResults = 1 }; ListResourcesResult 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; ListResourcesResult 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); }
public ListResourcesResult ListResources(ListResourcesParams parameters) { UrlBuilder urlBuilder = new UrlBuilder( m_api.ApiUrlV. ResourceType("resources"). Add(Api.GetCloudinaryParam <ResourceType>(parameters.ResourceType)). Add(!String.IsNullOrEmpty(parameters.Tag) ? String.Format("tags/{0}", parameters.Tag) : String.Empty). BuildUrl()); foreach (var param in parameters.ToParamsDictionary()) { urlBuilder.QueryString[param.Key] = param.Value.ToString(); } using (HttpWebResponse response = m_api.Call( HttpMethod.GET, urlBuilder.ToString(), null, null)) { ListResourcesResult result = ListResourcesResult.Parse(response); return(result); } }
/// <summary> /// Lists resources. /// </summary> /// <param name="parameters">The parameters.</param> public ListResourcesResult ListResources(ListResourcesParams parameters) { var url = m_api.ApiUrlV. ResourceType("resources"). Add(Api.GetCloudinaryParam <ResourceType>(parameters.ResourceType)); if (parameters is ListResourcesByTagParams) { var tagParams = (ListResourcesByTagParams)parameters; if (!String.IsNullOrEmpty(tagParams.Tag)) { url.Add("tags").Add(tagParams.Tag); } } if (parameters is ListResourcesByModerationParams) { var modParams = (ListResourcesByModerationParams)parameters; if (!String.IsNullOrEmpty(modParams.ModerationKind)) { url .Add("moderations") .Add(modParams.ModerationKind) .Add(Api.GetCloudinaryParam <ModerationStatus>(modParams.ModerationStatus)); } } UrlBuilder urlBuilder = new UrlBuilder( url.BuildUrl(), parameters.ToParamsDictionary()); using (HttpWebResponse response = m_api.Call( HttpMethod.GET, urlBuilder.ToString(), null, null)) { ListResourcesResult result = ListResourcesResult.Parse(response); return(result); } }
private void AssertListResourcesByTagResult(ListResourcesResult result) { Assert.AreEqual(2, result.Resources.Count()); }
private void AssertListResourcesByTagResult(ListResourcesResult result) { Assert.AreEqual(2, result.Resources.Count(), result.Error?.Message); }
public PropertyController(AppDbContext appDbContext) { this.appDbContext = appDbContext; houseImages = cloudinary.ListResourcesByTag("RentSpace"); }