简体   繁体   中英

Storing images in a database

I realise that this is quite a broad question, so any general guidance would be helpful.

I have an app, whereby data is downloaded from a sever, and displayed in a table view. Each entry to the tableview also has a picture associated with it. This is where i'm stuck. Do I somehow store the image on my FTP server, and include a link to the image? Or do I directly store the image in the database? Are there any tutorials explaining how to do this?

I would say store image path as I'd image file system access to be faster than database.

Read what Facebook do/say.

You can either store the path to your file as a VARCHAR field, but then have to verify the data really exists (someone might have deleted the file and the record in the DB won't indicate that), or you store the image itself as a BLOB field.
The 2nd approach is more consistent, but makes the DB larger and make you handle BLOB fields. I'd go with the 1st one unless you really need to store the image in the DB.

最好的方法是将图像路径存储在 ,因为这是良好的性能,并且在使用目录时可以更好地控制它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM