Batch modify girdfs file content_type

     In the scenario, you forget to add content_type when writing a file, which results in the default stream type. When the browser accesses the file, it is downloaded directly from the stream, so it cannot be directly opened and displayed on the page.
     Modify the content_type of the girdfs file in batches

:
    
       db.fs.files.update({"filename": /.*\.pdf/ },{ $set : { "contentType" : "application/pdf" } },false,true);

       db.fs.files.update({"filename": /.*\.png/ },{ $set : { "contentType" : "image/png" } },false,true);
     



Query: bd.fs.files.find(filename:”uploads/payment_info/path/00/09/62/ebbc0565-5abd-4e8c-857c-480cd34fc35e.pdf”)

Delete: db.fs.files.remove({filename :/^uploads\/pament_info\/path/});


Tutorial:
http://www.ziqiangxuetang.com/mongodb/mongodb-update.html
http://www.ziqiangxuetang.com/mongodb/mongodb-atomic-operations .html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326475387&siteId=291194637