简体   繁体   English

Doctrine 2 ODM MongoDB从内存将图像存储在GridFS中

[英]Doctrine 2 ODM MongoDB storing images in GridFS from memory

i want to store uploaded files in mongodb as GridFsFile. 我想将上载的文件作为GridFsFile存储在mongodb中。 Im using the doctrine 2 odm. 我使用的是教义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? 是否可以直接存储二进制字符串?

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. 根据该问题的答案,PHP始终将上传的文件写入一个临时目录,而_FILES数组仅指向这些上传的文件。

You might consider setting PHP's upload_tmp_dir to a directory you've mounted as tmpfs or ramfs to avoid writing the files to disk. 您可能会考虑将PHP的upload_tmp_dir设置为以tmpfsramfs挂载的目录,以避免将文件写入磁盘。 see here for a comparison of the two memory-based file systems. 请参阅此处以比较两个基于内存的文件系统。

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

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