Hi Yumin
a = fs.put("C:\Users\BAL_SP_EQUITY_57_25102016.pdf")
But it doesn’t work
The code you posted does work, but not in the manner you expect. It will put the string “C:\Users\BAL_SP_EQUITY_57_25102016.pdf” into GridFS instead of the pdf file. This is because the fs.put() method requires an instance of str (bytes in python 3) or a file-like object providing a read() method (see http://api.mongodb.com/python/current/api/gridfs/index.html#gridfs.GridFS.put).
To store the actual pdf file, you would need to open the pdf file first, and pass the file handle into the fs.put() method. For example:
f = open("C:\Users\BAL_SP_EQUITY_57_25102016.pdf", "rb")
a = fs.put(f, filename="BAL_SP_EQUITY_57_25102016.pdf")
You may find these links helpful:
Best regards,
Kevin