How to load a pickle file from S3 to use in AWS Lambda?

前端 未结 3 1618
萌比男神i
萌比男神i 2020-12-13 20:27

I am currently trying to load a pickled file from S3 into AWS lambda and store it to a list (the pickle is a list).

Here is my code:

import pickle
im         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 21:11

    This is the easiest solution. You can load the data without even downloading the file locally using S3FileSystem

    from s3fs.core import S3FileSystem
    s3_file = S3FileSystem()
    
    data = pickle.load(s3_file.open('{}/{}'.format(bucket_name, file_path)))
    

提交回复
热议问题