Пример #1
0
        public void TestDelete()
        {
            // should allow deleting resources

            ImageUploadParams uploadParams = new ImageUploadParams()
            {
                File     = new FileDescription(m_testImagePath),
                PublicId = "testdelete"
            };

            m_cloudinary.Upload(uploadParams);

            GetResourceResult resource = m_cloudinary.GetResource("testdelete");

            Assert.IsNotNull(resource);
            Assert.AreEqual("testdelete", resource.PublicId);

            DelResResult delResult = m_cloudinary.DeleteResources(
                "randomstringopa", "testdeletederived", "testdelete");

            Assert.AreEqual("not_found", delResult.Deleted["randomstringopa"]);
            Assert.AreEqual("deleted", delResult.Deleted["testdelete"]);

            resource = m_cloudinary.GetResource("testdelete");

            Assert.IsTrue(String.IsNullOrEmpty(resource.PublicId));
        }
Пример #2
0
        public void Delete(Room room)
        {
            var roomEntity = _mapper.Map <RoomEntity>(room);
            var imageId    = GetResourceIdFromUrl(roomEntity.ImageUrl);

            _roomRepository.Delete(roomEntity);
            _cloudinary.DeleteResources(imageId);
        }
Пример #3
0
        public void ClearImages(string userToken)
        {
            var baseImages  = new List <string>();
            var cloudImages = new List <string>();

            if (IsAdmin(userToken))
            {
                using (var _connection = new SqlConnection(Global.WaifString))
                {
                    _connection.Open();
                    using (var cmd = new SqlCommand("SELECT Image FROM Users UNION SELECT Image FROM " +
                                                    "Waifu UNION SELECT Image FROM Anime", _connection))
                    {
                        using (var rd = cmd.ExecuteReader())
                        {
                            while (rd.Read())
                            {
                                baseImages.Add(rd["Image"].ToString());
                            }
                        }
                    }
                }
                Account shin = new Account(
                    "shingami322",
                    "245454634769229",
                    "rhdYXDZ5jXghrGWi3U2YZQPVPBg"
                    );

                Cloudinary cloudinary     = new Cloudinary(shin);
                var        cloudResources = cloudinary.ListResources();
                cloudImages = cloudResources.Resources.Where(x => !baseImages.Contains(x.Uri.ToString())).Select(x => x.PublicId).ToList();
                cloudinary.DeleteResources(cloudImages.ToArray());
            }
        }
        public string DeleteProducts()
        {
            var AllProducts = repo.GetAll().ToList();

            string status = "No Products To Delete";

            foreach (var product in AllProducts)
            {
                if (product.quantityAvailable < 1)
                {
                    status = "Product To Delete Found";
                    var publicId = this.GetPublicId(product.productImageUrl);

                    var delParams = new DelResParams()
                    {
                        PublicIds = new List <string>()
                        {
                            publicId
                        },
                        Invalidate = true
                    };

                    var deleteresult = cloudinary.DeleteResources(delParams);

                    repo.Delete(product.Id);
                    status += product.prodCode + " - Deleted";
                }
                repo.Commit();
            }

            return(status);
        }
Пример #5
0
        public async Task <IActionResult> Delete(string[] ids)
        {
            Cloudinary cloudinary = CloudAccount.Cloud();

            for (int g = 0; g < ids.Count(); g++)
            {
                var collectionsFinded = Context.Collections.Include(c => c.User).Where(u => u.UserId.Equals(ids[g]));
                foreach (Collection collection in collectionsFinded)
                {
                    cloudinary.DeleteResources(collection.ImageCloudId);
                }
            }
            for (int i = 0; i < ids.Count(); i++)
            {
                User usr = await userManager.FindByIdAsync(ids[i]);

                await userManager.DeleteAsync(usr);
            }
            string signeduserId = userManager.GetUserId(HttpContext.User);

            for (int i = 0; i < ids.Count(); i++)
            {
                if (ids[i].Equals(signeduserId))
                {
                    return(RedirectToAction("Logout", "Entrance"));
                }
            }

            return(View("UsersManager", userManager.Users));
        }
Пример #6
0
        public ActionResult Edit(HttpPostedFileBase image, Brand brand, string oldimg)
        {
            db.Entry(brand).State = EntityState.Modified;
            db.Entry(brand).Property(t => t.status).IsModified = false;
            if (image == null)
            {
                db.Entry(brand).Property(m => m.image).IsModified = false;
            }
            else
            {
                var myAccount = new Account {
                    ApiKey = "826331127339442", ApiSecret = "8SQi6Vti80ZwES3LeeBDFnSqBWQ", Cloud = "dycqowxvx"
                };
                Cloudinary _cloudinary = new Cloudinary(myAccount);

                //delete
                _cloudinary.DeleteResources(oldimg);

                //upload
                var uploadParams = new ImageUploadParams()
                {
                    File = new FileDescription(image.FileName, image.InputStream)
                };
                var uploadResult = _cloudinary.Upload(uploadParams);
                brand.image = uploadResult.SecureUri.AbsoluteUri;
            }


            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #7
0
        public async Task <IActionResult> DeleteUserByEmail(string email)
        {
            var response = new
            {
                status = 404,
                errors = new List <string>()
                {
                    "Account Not Found"
                }
            };

            var otherResponse = new
            {
                status = 401,
                errors = new List <string>()
                {
                    "Not Authorized"
                }
            };

            // Find this user by looking for the specific id
            var user = await _context.Users.FirstOrDefaultAsync(user => user.Email == email);

            if (user == null)
            {
                // There wasn't a user with that id so return a `404` not found
                return(NotFound(response));
            }

            var currentUser = await _context.Users.FindAsync(GetCurrentUserId());

            if (currentUser.Tier < 3)
            {
                return(Unauthorized(response));
            }

            //Caputes photos id's of the vehicle being deleted
            var photos = user.Media
                         .Where(photo => photo.PublicId != "")
                         .Select(photo => photo.PublicId).ToList();

            // Removes Media Files From Cloudinary
            var cloudinaryClient = new Cloudinary(new Account(CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, CLOUDINARY_API_SECRET));
            var delResParams     = new DelResParams()
            {
                PublicIds = new List <string>(photos)
            };

            cloudinaryClient.DeleteResources(delResParams);

            // Tell the database we want to remove this record
            _context.Users.Remove(user);

            // Tell the database to perform the deletion
            await _context.SaveChangesAsync();

            // Return a copy of the deleted data
            return(Ok(user));
        }
Пример #8
0
        public void DeleteImage(string token)
        {
            var cloudinary      = new Cloudinary(Credentials);
            var paramCollection = new string[] {
                token
            };

            cloudinary.DeleteResources(paramCollection);
        }
Пример #9
0
        public void DeleteImage(string link)
        {
            var urlTrimmed = link.Substring(link.LastIndexOf("/", StringComparison.Ordinal) + 1);
            var id         = urlTrimmed.Remove(urlTrimmed.LastIndexOf(".", StringComparison.Ordinal));

            var mCloudinary = new Cloudinary(_account);

            mCloudinary.DeleteResources(id);
        }
Пример #10
0
 public async Task <IActionResult> DeletePhoto(Photo photo)
 {
     if (await _repo.Delete <Photo>(photo))
     {
         _cloudinary.DeleteResources(photo.PublicId);
         return(Ok(photo));
     }
     return(BadRequest("Error deleting photo"));
 }
Пример #11
0
        /// <summary>
        /// function that deletes a picture from the cloud
        ///</summary>
        /// <param name="publicID">
        /// string that contains the Picture's Public ID
        ///</param>
        ///<returns>
        /// void
        ///</returns>
        public void DeletePictureFromCloud(string publicID)
        {
            var result = _cloudinary.DeleteResources(publicID);

            if (result.Error != null)
            {
                throw new Exception("Encountered an error while processing the request");
            }
        }
Пример #12
0
        public void DeleteResources()
        {
            Cloudinary cloudinary = TestUtilities.GetCloudinary();

            TestUtilities.UploadImageWithName();
            Debugger.Break();
            DelResResult delResResult = cloudinary.DeleteResources("zombie");

            TestUtilities.LogAndWrite(delResResult, "DeleteResources.txt");
        }
        public async Task <DelResResult> DeleteImage(string publicId)
        {
            var delParams = new DelResParams {
                PublicIds = new List <string> {
                    publicId
                }, Invalidate = true
            };

            return(_cloudinary.DeleteResources(delParams));
        }
 public void DeleteImage(string[] ids)
 {
     try
     {
         Cloudinary cloudinary   = new Cloudinary(account);
         var        uploadResult = cloudinary.DeleteResources(ids);
     }
     catch
     {
     }
 }
Пример #15
0
        public async Task <IActionResult> DeleteAddress(int id)
        {
            // Find this vehicle by looking for the specific id
            var address = await _context.Addresses
                          .FirstOrDefaultAsync(dealer => dealer.Id == id);

            if (address == null)
            {
                // There wasn't a vehicle with that id so return a `404` not found
                return(NotFound());
            }

            // Find the user information of the user that called a delete request
            var user = await _context.Users.FindAsync(GetCurrentUserId());

            if (user.Tier < 3)
            {
                // Make a custom error response
                var response = new
                {
                    status = 401,
                    errors = new List <string>()
                    {
                        "Not Authorized"
                    }
                };

                // Return our error with the custom response
                return(Unauthorized(response));
            }

            // Caputes photos id's of the vehicle being deleted
            var photos = address.Media
                         .Where(photo => photo.PublicId != "")
                         .Select(photo => photo.PublicId).ToList();

            // Removes Media Files From Cloudinary
            var cloudinaryClient = new Cloudinary(new Account(CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, CLOUDINARY_API_SECRET));
            var delResParams     = new DelResParams()
            {
                PublicIds = new List <string>(photos)
            };

            cloudinaryClient.DeleteResources(delResParams);

            // Tell the database we want to remove this record
            _context.Addresses.Remove(address);

            // Tell the database to perform the deletion
            await _context.SaveChangesAsync();

            // Return a copy of the deleted data
            return(Ok(address));
        }
Пример #16
0
        public async Task <string> DeletePhoto(int id)
        {
            var photo = await _db.Photos.FirstOrDefaultAsync(p => p.Id == id);

            _cloudinary.DeleteResources(photo.PublicId);

            _db.Photos.Remove(photo);
            await _db.SaveChangesAsync();

            return("Xóa thành công");
        }
Пример #17
0
        public void DeletePictureAsync(string fileName)
        {
            var delResParams = new DelResParams()
            {
                PublicIds = new List <string> {
                    fileName
                }
            };

            var delResult = _cloudinaryUtility.DeleteResources(delResParams);
        }
Пример #18
0
        public async Task <IActionResult> DeleteDeveloper([FromRoute] int?id, [FromForm] int formId)
        {
            if (id != formId)
            {
                return(BadRequest());
            }

            var devForDeletion = await _repo.GetDeveloper(id);

            if (devForDeletion == null)
            {
                return(NotFound());
            }

            List <string> photosForDeletion = new List <string>();

            if (devForDeletion.PhotoId != null)
            {
                photosForDeletion.Add(devForDeletion.PhotoId);
            }

            if (devForDeletion.Games.ToList().Count > 0)
            {
                foreach (Game game in devForDeletion.Games)
                {
                    if (!String.IsNullOrEmpty(game.PhotoId))
                    {
                        photosForDeletion.Add(game.PhotoId);
                    }
                }
            }

            if (photosForDeletion.Count > 0)
            {
                var delParams = new DelResParams()
                {
                    PublicIds = photosForDeletion
                };

                _cloudinary.DeleteResources(delParams);
            }

            _repo.Delete(devForDeletion);

            if (await _repo.SaveAll())
            {
                SetMessage("info", "Developer deleted");
                return(RedirectToAction(nameof(Index)));
            }

            SetMessage("danger", "Something went wrong. Could not complete request");
            return(RedirectToAction(nameof(Index)));
        }
Пример #19
0
        public void DeleteResource(string publicId)
        {
            var delParams = new DelResParams()
            {
                PublicIds = new List <string>()
                {
                    publicId
                }, Invalidate = true
            };

            _cloudinary.DeleteResources(delParams);
        }
Пример #20
0
        public bool DeletePhoto(string publicId)
        {
            var deletionSucceeded = false;

            if (_cloudinaryAccount != null)
            {
                var deleteResult = _cloudinaryAccount.DeleteResources(new string[] { publicId });
                deletionSucceeded = deleteResult.Deleted.ContainsValue("deleted");
            }

            return(deletionSucceeded);
        }
Пример #21
0
        public ActionResult GalleryDel(string link)
        {
            var myAccount = new Account {
                ApiKey = "555682285552641", ApiSecret = "Id-vLH2JZBKc7x0wK3ZEZYCsGkA", Cloud = "dmrx96yqx"
            };
            Cloudinary _cloudinary = new Cloudinary(myAccount);
            int        pos         = link.LastIndexOf("placeOfBueaty/Gallery/");
            string     delImg      = link.Substring(pos, link.Length - pos - 4);

            _cloudinary.DeleteResources(delImg);
            return(RedirectToAction("Gallery", "Home"));
        }
Пример #22
0
 public static bool DeleteFile(string publicId)
 {
     try
     {
         cloudinary.DeleteResources(publicId);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #23
0
        public virtual void Cleanup()
        {
            foreach (ResourceType resourceType in Enum.GetValues(typeof(ResourceType)))
            {
                m_cloudinary.DeleteResources(new DelResParams()
                {
                    Tag = m_apiTag, ResourceType = resourceType
                });
            }

            m_cloudinary.DeleteResources(new DelResParams()
            {
                Tag = m_apiTag, ResourceType = ResourceType.Raw, Type = STORAGE_TYPE_PRIVATE
            });

            foreach (var prefix in new[] { m_folderPrefix, m_apiTest })
            {
                m_cloudinary.DeleteResourcesByPrefix(prefix);
            }

            foreach (var item in m_publicIdsToClear)
            {
                if (item.Value.Count == 0)
                {
                    continue;
                }

                m_cloudinary.DeleteResources(new DelResParams()
                {
                    Type         = item.Key.ToString(),
                    PublicIds    = item.Value,
                    ResourceType = ResourceType.Image
                });
            }

            m_transformationsToClear.ForEach(t => m_cloudinary.DeleteTransform(t.ToString()));
            m_presetsToClear.ForEach(p => m_cloudinary.DeleteUploadPreset(p));
            FoldersToClear.ForEach(f => m_cloudinary.DeleteFolder(f));
            m_metadataFieldsToClear.ForEach(p => m_cloudinary.DeleteMetadataField(p));
        }
Пример #24
0
        public IActionResult Delete(string[] ids)
        {
            Cloudinary cloudinary = CloudAccount.Cloud();

            for (int i = 0; i < ids.Count(); i++)
            {
                Collection collection = Context.Collections.Find(ids[i]);
                cloudinary.DeleteResources(collection.ImageCloudId);
                Context.Collections.Remove(collection);
                Context.SaveChanges();
            }
            return(RedirectToAction("MyCollections", "Collection"));
        }
Пример #25
0
        public static void DeleteImage(Cloudinary cloudinary, string name)
        {
            var delParams = new DelResParams()
            {
                PublicIds = new List <string>()
                {
                    name
                },
                Invalidate = true,
            };

            cloudinary.DeleteResources(delParams);
        }
Пример #26
0
        //delete a number of images
        public void Delete(List <string> paths)
        {
            if (!paths.Any())
            {
                return;
            }
            List <string> ids = new List <string>();

            foreach (var path in paths)
            {
                string id = Path.GetFileNameWithoutExtension(path);
                ids.Add(id);
            }

            var delParams = new DelResParams()
            {
                PublicIds  = ids,
                Invalidate = true
            };

            _cloudinary.DeleteResources(delParams);
        }
Пример #27
0
        private static void DeleteCloudinaryProfileImage(string username, string applicationName)
        {
            Cloudinary cloudinaryDelete = new Cloudinary(cloudinaryAccount);
            string     profileImageURL  = String.Format(@"{0}/{1}/{2}", cloudinaryAccountsFolder, applicationName, username);

            var delParams = new DelResParams()
            {
                PublicIds = new List <string>()
                {
                    profileImageURL
                },
                Invalidate = true
            };
            DelResResult result = cloudinaryDelete.DeleteResources(delParams);
        }
        public IActionResult ImageSil(int id)
        {
            UrunImage entity = imageRepo.GetbyId(id);

            if (entity != null)
            {
                Account    acc        = new Account("naimmobilya", "742112311237693", "nqeO8i7tnQpNPnSAQyESOqImU-I");
                Cloudinary cloudinary = new Cloudinary(acc);
                cloudinary.DeleteResources(entity.UrunImageId.ToString());
                imageRepo.Delete(entity);
                TempData["message"] = $"{entity.UrunId} id li image silindi";
            }

            return(RedirectToAction("UrunDuzenle", new { id = entity.UrunId }));
        }
Пример #29
0
        public static void DeleteImage(Photo photo)
        {
            Account account = new Account(CloudinarySettings.CloudName, CloudinarySettings.ApiKey, CloudinarySettings.ApiSecret);

            Cloudinary cloudinary = new Cloudinary(account);

            var delResParams = new DelResParams()
            {
                PublicIds = new List <string> {
                    photo.PublicId
                }
            };

            cloudinary.DeleteResources(delResParams);
        }
Пример #30
0
        public string DeleteCloudinaryImg(string publicId)
        {
            var delParams = new DelResParams()
            {
                PublicIds = new List <string>()
                {
                    publicId
                },
                Invalidate = true
            };

            var delResult = cloudinary.DeleteResources(delParams);

            return(null);
        }