All Projects β†’ sanketsaurav β†’ s3tree

sanketsaurav / s3tree

Licence: MIT license
🌲 Access S3 like a tree.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to s3tree

Minio Java
MinIO Client SDK for Java
Stars: ✭ 444 (+1607.69%)
Mutual labels:  libraries, aws-s3
black-postoffice
[무신사 μ‹ μž…] 읡λͺ…μœΌλ‘œ νŽΈν•˜κ²Œ κ³ λ―Ό, 일상을 κ³΅μœ ν•˜λŠ” μ†Œμ…œ λ„€νŠΈμ›Œν¬ μ„œλΉ„μŠ€μž…λ‹ˆλ‹€.
Stars: ✭ 31 (+19.23%)
Mutual labels:  aws-s3
snatchblock
A strictly typed utility library.
Stars: ✭ 1,059 (+3973.08%)
Mutual labels:  utility-library
isepic-chess
β™ž JavaScript chess utility library.
Stars: ✭ 16 (-38.46%)
Mutual labels:  utility-library
koel-aws
Official Lambda package and guide to use AWS S3 with Koel
Stars: ✭ 23 (-11.54%)
Mutual labels:  aws-s3
s3cli
Command line tool for S3
Stars: ✭ 21 (-19.23%)
Mutual labels:  aws-s3
DPTLib
My C libraries
Stars: ✭ 20 (-23.08%)
Mutual labels:  utility-library
moments v2 backend
backend for a sharing app using SpringBoot, Redis, MySQL, and AWS S3.
Stars: ✭ 54 (+107.69%)
Mutual labels:  aws-s3
django-s3file
A lightweight file upload input for Django and Amazon S3
Stars: ✭ 66 (+153.85%)
Mutual labels:  aws-s3
Awesome-CSS-Frameworks-and-UI-Libraries
Extensive List of CSS Frameworks and UI Libraries.
Stars: ✭ 110 (+323.08%)
Mutual labels:  libraries
Meteor-Files-Demo
Demo application for ostrio:files package
Stars: ✭ 16 (-38.46%)
Mutual labels:  aws-s3
s3-utils
Utilities and tools based around Amazon S3 to provide convenience APIs in a CLI
Stars: ✭ 45 (+73.08%)
Mutual labels:  aws-s3
Differentia.js
No longer being supported or maintained. A Graph Theory & Data Structure Library for JavaScript.
Stars: ✭ 13 (-50%)
Mutual labels:  utility-library
libs.kmp.icerock.dev
Kotlin Multiplatform libraries list with info auto-fetch
Stars: ✭ 178 (+584.62%)
Mutual labels:  libraries
CoCoC
C development system for (Nitr)OS9/6x09, with source
Stars: ✭ 22 (-15.38%)
Mutual labels:  libraries
cloud-sql-python-connector
Cloud SQL Connector for Python
Stars: ✭ 126 (+384.62%)
Mutual labels:  libraries
rgutil
rgutil是基于ES6εˆ›ε»Ίηš„ε‡½ζ•°εΊ“ε·₯ε…·
Stars: ✭ 22 (-15.38%)
Mutual labels:  utility-library
mlflow-tracking-server
MLFLow Tracking Server based on Docker and AWS S3
Stars: ✭ 59 (+126.92%)
Mutual labels:  aws-s3
tug
Private Composer registry for private PHP packages on AWS Serverless
Stars: ✭ 33 (+26.92%)
Mutual labels:  aws-s3
terraform-aws-logs
Creates and configures an S3 bucket for storing AWS logs.
Stars: ✭ 69 (+165.38%)
Mutual labels:  aws-s3

S3Tree 🌲

DeepSource Build Status Coverage Status

S3Tree allows you to access files stored on Amazon AWS S3 as a simple directory tree. You can traverse the tree and read files as easily as you os.walk.

>>> import s3tree
>>> s3tree.config.aws_access_key_id = '<AWS-ACCESS-KEY>'
>>> s3tree.config.aws_secret_access_key = '<AWS-SECRET-KEY>'
>>> tree = s3tree.S3Tree(bucket_name='my-awesome-bucket')
>>> len(tree)
77
>>> for obj in tree: print(obj.name)
...
admin
assets
...
index.js

Installation

To install S3Tree, use pipenv (or pip):

$ pipenv install s3tree

Documentation

Using AWS credentials

The s3tree module exposes a config object that can be used to set the AWS credentials you want to use globally. You should ideally do this before you make any instances of S3Tree.

>>> import s3tree
>>> s3tree.config.aws_access_key_id = '<AWS-ACCESS-KEY>'
>>> s3tree.config.aws_secret_access_key = '<AWS-SECRET-KEY>'

Credentials can also be passed while creating an S3Tree instance:

>>> tree = s3tree.S3Tree('dummy-bucket', aws_access_key_id='<AWS-ACCESS-KEY>', aws_secret_access_key='<AWS-SECRET-KEY>')

Passing the credentials during instance creation overrides the global config.

Fetching a tree

The S3Tree object represents a tree at any given path. The path can be specified while creating a new tree. If no path, or / is passed, the root if the bucket is fetched.

>>> tree = s3tree.S3Tree(bucket_name='dummy')  # tree at the root of the bucket `dummy`
>>> tree = s3tree.S3Tree(bucket_name='dummy', path='/admin/css')  # tree under the path `/admin/css`
>>> tree = s3tree.S3Tree(bucket_name='dummy', path='admin/css')  # this works too.

The tree object above is an iterable that contains all files and directories in this tree. len(tree) gives you the total size of this tree. If you want to access files and directories separately:

>>> tree.directories  # iterable for all the directories in the tree
>>> tree.files  # iterable for all the files in the tree

The S3Tree object can be easily represented as JSON:

>>> tree.as_json

The Directory object

Each element in tree.directories is a Directory object. This has attributes that help you display the directory in a human-friendly manner, and methods to fetch the tree under itself.

>>> mydir = tree.directories[0]
>>> mydir.name  # the name of this directory
css
>>> mydir.path  # the full path of this directory
/admin/css
>>> child_tree = mydir.get_tree()  # retrieve and store the tree under `mydir` to `child_tree`
>>> json_data = mydir.as_json  # JSON representation of this directory

The File object

Each element in tree.files is a File object, which has attributes and methods to display properties and read the file.

>>> myfile = tree.files[0]
>>> myfile.name  # name of this file
index.js
>>> myfile.size  # human-readable size of this file
4 KB
>>> contents = myfile.read()  # reads the file and stores its contents in `contents`
>>> json_data = myfile.as_json  # JSON representation of this file obj
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].