Ad
How To Save A Python Dictionary As A Pickle Object On AWS S3
I have a python dictionary. I want to save it as a pickle object in AWS S3.
I am trying this -
import boto3
import pickle
#Connect to S3 default profile
s3 = boto3.client('s3')
serializedMyData = pickle.dumps(myDictionary)
s3.put_object(Bucket='mytestbucket',Key='myDictionary')
The script runs successfully and I get a file with name * myDictionary* in the S3. But it is not a pickle and it has 0 bytes.
I edited my code a little bit -
import boto3
import pickle
#Connect to S3 default profile
s3 = boto3.client('s3')
serializedMyData = pickle.dumps(myDictionary)
s3.put_object(Bucket='mytestbucket',Key='myDictionary').put(Body=serializedMyData)
But then I get this error -
AttributeError: 'dict' object has no attribute 'put'
What should I do ?
Ad
Answer
Try s3.put_object(Bucket='mytestbucket',Key='myDictionary', Body=serializedMyData)
see https://docs.aws.amazon.com/code-samples/latest/catalog/python-s3-put_object.py.html
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad