In the cakephp 2.0 application i'm developing i will need a HABTM relationship between a table with "normal" data and one with stored images.
After a search, i came to conclude that the best way of implementing this was to store the images in the directory of the application, and in the table "images" a reference to the url of each image so that i can display them later on the application. Please, if you think this is not the best implementation please say so.
Looking into this, i would like to know how can i do this, i mean, how can i store the images on directory and store a reference in a database in the same function of a controller?
I did some searchs but i found only uploading to folders or only storing the images on database.
Thank you!
My FileStorage plugin https://github.com/burzum/FileStorage in combination with the https://github.com/CakeDC/Imagine plugin will exactly do what you want.
All file data is stored in the database, the files itself in the local file system or any of the other adapters. It's also handling generating versions of the image after upload.
Read the readme.md it is exactly doing what you want and I'm already using it in different projects, also for a gallery and user avatars.
Related
I have an e-commerce react app, so as you know every product has at least three or four images, so to show the image of product in my website i created a folder with a name of " images " inside the public folder so everytime i want to show images of a specific product i can get and show them very simply and for Now this is very very awesome.
The Problem:
as we know each e-commerce website should have an admin where he can publish new products and upload new images, so by the time may be i will have thousands of images in my website.
Question
what is the best practice to store images of my react app ?
do i need to use third party like AWS or Firebase ?
Thank you.
Storing images in the code-base assets folder is not the best option for large number of images. Handling updates, inserts is a big problem. So you have the following options.
Options: Cloud/On Premises
You may store in the cloud like AWS S3
If you want to store on premises, you may store in MongoDB Grids
or even on the File System with file-path stored in the database.
Step Ahead
But going ahead you might need responsive images according to the image placeholder. Example for an image you might need thumbnails of different sizes lets say for listing pages, android apps, iOS apps.You might also need to compress the images in case they are heavy for web purpose.
In that case you may choose to store the images in the desired
resolutions.For this you'll have to store multiple versions on an image. For example product1/original.jpg, product1/compressed.jpg, product1/300x300.jpg etc
You may resize/crop the images on the fly. If you want to write your resizing systems you may write ImageMagick/vips/PIL etc based code.You may try to search for readymade nginx based plugins to server responsive images.
If you do not want to do this resizing stuff yourself you may use image storage services like imgix,cloudinary,akamai that provides CDN + image manipulations.Some of these provide storage+manipulation while some only manipulation.
I have created a video editor using React Native. I need to choose a way to save all of the user's projects locally. Each project has a video file, thumbnails (images) and its current Redux state.
My first idea is to save everything in files using RNFS. Each Project's folder would have a video file, Thumbnails folder and a state.txt file containing my application's current state (current text size selected, background color, etc...).
Do I need a database like SQLITE or should I save everything in files? I know I'll have to use RNFS for the binary data like videos and images. But what about the state.txt file? is that a good idea? The idea of each user having their own local database just for that sounds strange to me.
You have your Redux state that just represents local state. Have a look at https://github.com/rt2zz/redux-persist
This allows you to serialize the Redux State and save it using whatever storage you provide, but you can use asyncStorage in the react native apps.
You are right about using RNFS for videos etc. For the metadata in state.txt, in my opinion, it would be better to go with async-storage or other offline storage options (like Realm )
It will be much more performant to query it instead of reading from a file.
I want to upload the image in my website. The same image will be shown in another website. So this is the scenario where image is uploaded in one website and displayed in both website. These two websites are hosted in two different servers as well as they both have their own database.
I am using Angular JS, Entity Framework, Web API and SQL Server 2014 as backend for both of the website. Currently I am using ngFileUpload to upload the images. Please answer me on below questions:-
Should I upload the image in database(as nvarchar-max) or filesystem(FTP or local web server file system)? I read many articles and get to know that Database retrieval of image has affect on performance but it is more secured. However File System is easy in performance but complex on maintenance like back ups. So I am just not able to decide which to choose among these two as both have pros and cons. Which option will be more suitable to my requirement where same image will be displayed in both website. Please note that there can big images like upto 5 MB uploaded in the application but the number of images will not be huge as compare to any social networking or online shopping site.
How to create different size of images(thumbnail, medium, large etc) automatically upon uploading of image in website? Is there any tool or directive already available in Angular JS to achieve this?
I know my question is broad but I need suggestion to start with my requirements.
Please help.
I use the file system to host my images. If the image is displayed on someone's computer screen, they can use an image capturing software to copy it anyway. Also, while storing them to a database may be more secure, I don't need the extra overhead in my code where a simple url to retrieve the image will suffice.
As for resizing an image using Angular, check out these links:
https://www.scientiamobile.com/page/angular-image-resize
https://github.com/FBerthelot/angular-images-resizer
I am using basically the mean stack. I'm also using multer but I am trying to see what the best practices are. Using Angular I can upload photos fine and they are going to a folder on my file system. From here I can just view them. However I'm wondering what the best practices are. Should I save the image url to a database along with the size and other properties or should I just pull them from the client? I've seen some solutions but they were from about 2 years ago so I wanted to make sure I'm current.
I have used ng-file-upload upload on the angular part and Multer on the node.js part to handle images for my system.
The method is appropriate and you can go ahead without any doubt.
Most of the websites on the internet follow the same method, they save the images in the file disk system and then they save it's url in the respective database.
Using multer you can have all information required for a photo and the module is really flexible with a lot many options.
I think you should go ahead with what you have in mind. Best of luck.
You just save the image url from the directory, where image is stored. If you need any information, you can get the information from the image where image is stored (Get image from url). So just save image url into database.
I've been tasked to migrate a Joomla 1.7 site to Drupal, which is going fairly well, except that I can't find where Joomla stores image paths for articles in the database. In the jos_articles table I have the following columns:
id
title
subtitle
cat
atype
theme
topics
intro
description
geography
source
author
extraauthors
published
featured
created_date
publish_date
unpublish_date
modified_date
hits
Any ideas?
EDIT: figured it out - the template automatically looks for [article-id].jpg, which means they aren't stored in the database at all!!!
Nothing to see here folks...
Joomla keeps information from the articles and pages that you create in two places. First of all, the text of the articles are keep as records in a database. All Joomla sites use a database to keep a lot of the information that helps manager the site, and your articles (and links, and contact items, etc.) are in that database. Generally, the database is provided by a database called mySQL that is provided as part of your web hosting service. Joomla manages getting articles in and out of this for you automatically.
So, you will not find a “file” on your website that contains the text of your articles. It is stored away in the Joomla mySQL database.
Now, photos, icons, graphics, and things like that are not stored in the database. They are actually stored as files in the file system of your Joomla installation.
Check this Article:
http://welcometojoomla.com/how-do-i-articles/34-site-management/76-where-does-joomla-keep-the-articles
By reading below article you will get the answer.
Does joomla store article/ modules text and image path in database?
Where does Joomla store article images?
Where does Joomla keep the articles?
In Joomla 1.7 the Article image urls are stored inside the #__content table
It was saving image url inside the introtext column with the article content. The images are from different location like images/banners/ or from any folder that access from media manager.
Hope its helps.