Created
August 26, 2015 13:58
-
-
Save pkulev/3ad25df42e36d26b0d28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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