Doctrine 2 ODM MongoDB 从内存中将图像存储在 GridFS 中
我想将上传的文件作为 GridFsFile 存储在 mongodb 中。我使用的是 2 odm 原则。当我从磁盘读取文件并存储它时,它工作正常。但我想实现的是避免将上传的文件存储在文件系统上的任何位置。
是否可以直接存储二进制字符串?
i want to store uploaded files in mongodb as GridFsFile. Im using the doctrine 2 odm. it works fine when i read a file from disk and store it. But what i would like to achieve is to avoid storing the uploaded files anywhere on file system.
Is it possible to store the binary string directly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这个问题的答案,PHP总是将上传的文件写入一个临时目录,
_FILES
数组仅指向那些上传的文件。您可以考虑将 PHP 的
upload_tmp_dir
设置为已安装为tmpfs
或ramfs
的目录,以避免将文件写入磁盘。请参阅此处进行比较两个基于内存的文件系统。According to the answer to this question, PHP always writes uploaded files to a temporary directory, and the
_FILES
array just points to those uploaded files.You might consider setting PHP's
upload_tmp_dir
to a directory you've mounted astmpfs
orramfs
to avoid writing the files to disk. see here for a comparison of the two memory-based file systems.