How to auto-upload default images to staging server
I am setting up a staging server. My definition of a staging server is for "playing around on a server that is identical to production, but contains fake sample data".
On rails, specifically, we use "fixtures" to upload test data to the staging server. For instance:
profiles.yml
------------
username: "jane_doe"
city: Los Angeles
weight: 140 lb
profile_picture: {jane cloudinary image}
username: mary_lou
city: Chicago
weight: 110 lb
profile_picture: {mary cloudinary image}
In rails, the above file is called a "fixture" and we typically refresh the staging server database by typing "rake db:fixtures:load". However, I don't think it can handle the uploading of actual cloudinary files. It just updates plaintext and numbers, not cloudinary images, as far as I can tell.
Is there some sort of "cool" cloudinary tool in javascript that allows me to refresh the staging server with "clean" data, including the cloudinary images?
There may be a more proper name for this process, but I am unfamiliar with it, so it is difficult to google.
-
Official comment
Hi Steve, thanks for getting in touch.
i don't have any suggestions for wiping previous data, but for creating data when populating your staging env, you might have some luck using Faker. It's a JS library used to create fake user data including name, email, location, etc. This can also provide you with user avatars that you can upload to your Cloudinary account, but this will cost you in terms of storage.
What I would suggest instead is using a default image placeholder. This would allow you to have unique filenames for each user in the fixture, but all point to the same image. For instance you could have https://res.cloudinary.com/demo/image/upload/d_avatar.png/jane_doe.png and https://res.cloudinary.com/demo/image/upload/d_avatar.png/mary_lou.png, but because they're using
d_avatar.png
, if a file doesn't exist with their username, it will fall back to the default image.Have a look at this article - it explains the process in a bit more detail, and gives example code in Ruby too.
I hope this helps. If you have any further questions, please feel free to reply here or raise a support ticket if you prefer.
Thanks,
-DannyComment actions
Please sign in to leave a comment.
Comments
1 comment