Reading a JSON File
Learn how to read a JSON file stored in a Filebase bucket using Python & Boto3.
JSON is a file format featuring an open standard and interchangeable data format that uses human-readable text to store and transmit data objects that are formatted as arrays or value pairs.
Read below to learn how to use a Python script with Boto3 to read the contents of a JSON file that is stored in a Filebase bucket.
- Have a
.json
file stored in your Filebase bucket.
import boto3
import json
from botocore.config import Config
boto_config = Config(region_name = 'us-east-1',
signature_version = 's3v4')
s3 = boto3.client('s3',
endpoint_url = 'https://s3.filebase.com',
aws_access_key_id='filebase-access-key',
aws_secret_access_key='filebase-secret-key',
config=boto_config)
object = s3.get_object(Bucket='filebase-sample-bucket',Key='my_file.json')
j = json.loads(object['Body'].read())
print(j['Details'])
- Aws_access_key_id: Your Filebase Access Key
- Aws_secret_access_key: Your Filebase Secret Key
- Bucket: Your Filebase bucket name
- Key: Your JSON file to be read
- Replace ‘Details’ with the name of the property in your JSON file to read
If you have any questions, please join our Discord server, or send us an email at [email protected]
Last modified 1yr ago