草庐IT

Filename

全部标签

mongodb - 如何通过 PyMongo 和 Bottle 显示来自 MongoDB 数据库的图像?

期望的行为将图像上传到GridFS,然后在浏览器中显示它(只是为了了解GridFS的工作原理)。当前行为图像上传到GridFS集合(我可以通过shell访问它),然后返回500错误。错误Error:500InternalServerErrorSorry,therequestedURL'https:/mysite.com/form_action_path'causedanerror:表单Bottle#relevantlibrariesimportgridfsfrombottleimportresponse@route('/upload',method='POST')defdo_uploa

mongodb - 从 fs.files 投影一列

我想执行这个查询:db.fs.files.find({},{filename:1,_id:0})使用spring-data-mongodb(仅获取所有文件名)。有没有人知道如何解决这个问题?提前致谢。 最佳答案 选项1DBCollectionfsCollection=template.getCollection("fs.files");fsCollection.setObjectClass(null);DBCursorcursor=fsCollection.find(newBasicDBObject(),newBasicDBObje

javascript - 使用 gridfs-stream 执行 find() 时如何指定 GridFS 存储桶

使用gridfs-stream,查找和抓取文件时如何指定bucket名称?我的问题是在stackoverflow上发现的以下问题的后续问题HowcanIspecifyaGridFSbucket那里的解决方案提供了一个示例,说明如何在调用createWriteStream时指定存储桶。根据@vsivsi提供的代码,我可以使用以下代码中的“root”选项将文件添加到我的自定义存储桶://fyi,req.filehasbeenpopulatedusingmultervargfs=Grid(mongoose.connection.db);varwriteStream=gfs.createWri

前端如何获取响应头Content-Disposition中的filename

问题:后端在返回文件流时,将文件类型放在了响应头中,需要前端获取filename后手动添加文件名后缀。代码:前端:downloadFile(response,fileName){ constheaders=response.headers; constcontentType=headers['content-type']; constblob=newBlob([response.data],{type:contentType}); consttemp=response.headers['content-disposition']; letfilenameRegex=/filename[^;=\

java - Vaadin上传组件——直接上传到mongo仓库

我想在我的网络应用程序中使用vaadin上传组件,并以gridfs格式直接将文件上传到mongodb。我当前的实现使用一个临时存储位置来首先上传文件,然后存储在mongo中转换为gridfs。这是我的上传组件代码:我已经实现了Receiver接口(interface)方法recieveUploadprivateFilefile;privateStringtempFilePath;publicclassHandleUploadImplextendsCustomComponentimplementsUpload.SucceededListener,Upload.FailedListener

javascript - 在 MongoDb 中将数据存储为对象与数组以提高写入性能

考虑到写入速度,我应该将对象存储在数组中还是在最重要的对象中?我正在尝试决定是将数据存储为对象数组,还是在mongodb文档中使用嵌套对象。在这种特殊情况下,我正在跟踪我添加和更新的一组不断更新的文件,文件名充当键和文件中处理的行数。文档看起来像这样{t_id:1220,some-other-info:{},//there'sotherinfoherenotupdatedfrequentlyfiles:{log1-txt:{filename:"log1.txt",numlines:233,filesize:19928},log2-txt:{filename:"log2.txt",num

javascript - node.js上传下载pdf文件

框架:node.js/express.js/busboy/gridfs-stream(mongodb)我正在使用busboy上传文件,然后使用gridfs-stream将文件存储在mongodbgridfs中。req.pipe(req.busboy);req.busboy.on('file',function(bus_fieldname,bus_file,bus_filename){varwritestream=gfs.createWriteStream({filename:bus_filename,});bus_file.pipe(writestream);writestream.o

node.js - 在 MongoDB/NodeJs/GridFS 堆栈中从 GridFS 下载文件时出现问题

我正在开发NodeJsAPI,我选择使用GridFS来存储和下载文件。对于这个问题,我有两个API:上传和下载。当我使用Postman调用它们时,这两个API都工作得很好;但是我在使用浏览器下载文件时遇到问题。浏览器似乎看到了200HTTP代码,并希望在内容仍在流式传输时文件立即存在。因此,它提示图像或PDF等有错误或格式无效。唯一可用的文件类型是MP3,浏览器会为其启动播放该音乐的MP3流媒体插件。varGrid=require('gridfs-stream');Grid.mongo=mongoose.mongo;vargfs=newGrid(mongoose.connection.

mongodb - 错误 : "could not find implicit value for parameter readFileReader" trying to save a file using GridFS with reactivemongo

我正在尝试使用以下代码在Play2.1中使用reactivemongo保存附件:defupload=Action(parse.multipartFormData){request=>request.body.file("carPicture").map{picture=>valfilename=picture.filenamevalcontentType=picture.contentTypevalgridFS=newGridFS(db,"attachments")valfileToSave=DefaultFileToSave(filename,contentType)valfutur

c# - 为什么我多了一个角色?

您好,我正在使用此C#代码上传图片。protectedvoidUploadFile(objectsender,EventArgse){stringfilename=Path.GetFileName(FileUpload1.PostedFile.FileName);stringcontentType=FileUpload1.PostedFile.ContentType;using(Streamfs=FileUpload1.PostedFile.InputStream){using(BinaryReaderbr=newBinaryReader(fs)){byte[]bytes=br.Rea