Skip to content

Instantly share code, notes, and snippets.

@pkulev
Created Aug 26, 2015
Embed
What would you like to do?
import gridfs
import pymongo
conn = pymongo.MongoClient("mongodb://localhost:27017")
db = conn.test
videos_meta = db.videos_meta
def main():
grid_id = videos_meta.find_one({"filename": "video.mp4"})["grid_id"]
print("Filename grid id: %s" % grid_id)
grid = gridfs.GridFS(db, "videos")
print("File found: %s " % grid.exists(grid_id))
fd = grid.get(grid_id)
with open("video1.mp4", "wb") as fdout:
fdout.write(fd.read())
print("Done.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment