mongoDB: store audio files (Best way) using python
Question: I've a bunch of audio files (.wav) and I'd like know from you guys, what's the
best way to store them in mongoDB? What I'm doing today is, just storing the
path of the file.(as you can see below). But I think it's not good because I'm
creating a "fake reference" to the file and I wonder If by chance I delete the
file, how could I consist it?

    
    
    {
        "_id" : ObjectId("57c0a06cd92f49222ce2f42d"),
        "eps" : "GPSP",
        "terminal" : 989638523,
        "main_path" : "W:\\Python\\Speech\\audio\\teste\\teste_9",
        "motivo" : "Classic",
        "audio" : [ 
            {
                "path" : "W:\\Python\\Speech\\audio\\teste\\teste_9\\01_audio.wav",
                "confidence" : 0.8332507,
                "transcript" : "Alô bom dia com quem eu falo",
                "sequence" : 1
            }, 
            {
                "path" : "W:\\Python\\Speech\\audio\\teste\\teste_9\\02_audio.wav",
                "confidence" : 0.90813386,
                "transcript" : "Um novo benefício pra minha da senhora, sem impostos e nada mais do que isso",
                "sequence" : 2
            }
    }
    

Thank you,


Answer: Take a look at MongoDB
[`gridfs`](https://docs.mongodb.com/manual/core/gridfs/):

> GridFS is a specification for storing and retrieving files that exceed the
> BSON-document size limit of 16 MB

Using pymongo you can put files inside like this:

    
    
    from pymongo import MongoClient
    import gridfs
    
    fs = gridfs.GridFS(db)
    file_id = fs.put(open( r'audio.wav', 'rb')
    

