MongoDB使用命令行上传图片文件

来源:互联网 发布:海颐软件 编辑:程序博客网 时间:2024/05/19 12:18


在mongoDB环境变量配置好的前提下,使用mongodb的命令行上传一张图片。(Linux环境下)

mongofiles put --host 10.0.60.44 --port 27017 --db scity --local ~/IMG_20141129_114338.jpg photo.jpg --type jpg



其中:

     

--host  是mongodb的ip;--port  是端口号--db  是数据库的名称--local  要填2个参数,第一个是本地图片的路径,第二个是在数据库中的别名。--type  是保存的格式。

-help的输出如下:


Browse and modify a GridFS filesystem.usage: mongofiles [options] command [gridfs filename]command:  one of (list|search|put|get)  list - list all files.  'gridfs filename' is an optional prefix          which listed filenames must begin with.  search - search all files. 'gridfs filename' is a substring            which listed filenames must contain.  put - add a file with filename 'gridfs filename'  get - get a file with filename 'gridfs filename'  delete - delete all files with filename 'gridfs filename'Options:  --help                                produce help message  -v [ --verbose ]                      be more verbose (include multiple times                                        for more verbosity e.g. -vvvvv)  --quiet                               silence all non error diagnostic                                         messages  --version                             print the program's version and exit  -h [ --host ] arg                     mongo host to connect to ( <set                                         name>/s1,s2 for sets)  --port arg                            server port. Can also use --host                                         hostname:port  --ipv6                                enable IPv6 support (disabled by                                         default)  -u [ --username ] arg                 username  -p [ --password ] arg                 password  --authenticationDatabase arg          user source (defaults to dbname)  --authenticationMechanism arg (=MONGODB-CR)                                        authentication mechanism  --gssapiServiceName arg (=mongodb)    Service name to use when authenticating                                        using GSSAPI/Kerberos  --gssapiHostName arg                  Remote host name to use for purpose of                                         GSSAPI/Kerberos authentication  --dbpath arg                          directly access mongod database files                                         in the given path, instead of                                         connecting to a mongod  server - needs                                         to lock the data directory, so cannot                                         be used if a mongod is currently                                         accessing the same path  --directoryperdb                      each db is in a separate directory                                         (relevant only if dbpath specified)  --journal                             enable journaling (relevant only if                                         dbpath specified)  -d [ --db ] arg                       database to use  -c [ --collection ] arg               collection to use (some commands)  -l [ --local ] arg                    local filename for put|get (default is                                         to use the same name as 'gridfs                                         filename')  -t [ --type ] arg                     MIME type for put (default is to omit)  -r [ --replace ]                      Remove other files with same name after                                        PUT


0 0
原创粉丝点击