简体   繁体   English

将照片从iOS应用程序存储到服务器

[英]Storing Photos from iOS Application into server

My question is about performance. 我的问题是关于性能。 I've built an iOS application that takes photos and stores them into a database. 我已经构建了一个iOS应用程序,该应用程序可以拍摄照片并将其存储到数据库中。

Is it more efficient to store the base64_encoded image string into a database field or store the file in a folder and only store the file path in the database, then encode the image back into a base64_encoded image when it is retrieved by the application? 将base64_encoded图像字符串存储到数据库字段中或将文件存储在文件夹中,然后仅将文件路径存储在数据库中,然后在应用程序检索到该图像后将其编码回base64_encoded图像,效率更高吗?

My current approach is storing the image in a folder and converting it into a base64_encoded image string when the app fetches the images from the server. 我当前的方法是将图像存储在文件夹中,并在应用程序从服务器获取图像时将其转换为base64_encoded图像字符串。 I return them in groups of 15 images at a time and this works fine but there is a delay when the server is converting the 15 images into base64 string format. 我一次以15张图像的形式返回它们,效果很好,但是当服务器将15张图像转换为base64字符串格式时会有延迟。

Thanks for any opinions, suggestions or advice. 感谢您的任何意见,建议或建议。

Storing a whole image in a database in text format can hugely reduce performance. 以文本格式将整个图像存储在数据库中会极大地降低性能。 It is a better idea to store an URL that points to the image. 最好存储指向图像的URL。

This is application specific - What is your end goal? 这是特定于应用程序的-您的最终目标是什么? Storing base64 strings will be of a larger performance hit, simply because base64 strings can get quite large in size. 存储base64字符串将对性能产生更大的影响,仅因为base64字符串的大小可能会变得很大。 A path string would generally be smaller. 路径字符串通常较小。 But - if you don't store that image data, you don't own the data and if the path changes, your implementation will break. 但是-如果您不存储该图像数据,则说明您不拥有该数据,并且如果路径发生更改,您的实现也会中断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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