How to import a text file on AWS S3 into pandas without writing to disk

pandas uses boto for read_csv, so you should be able to: import boto data = pd.read_csv(‘s3://bucket….csv’) If you need boto3 because you are on python3.4+, you can import boto3 import io s3 = boto3.client(‘s3′) obj = s3.get_object(Bucket=”bucket”, Key=’key’) df = pd.read_csv(io.BytesIO(obj[‘Body’].read())) Since version 0.20.1 pandas uses s3fs, see answer below.

Boto3 to download all files from a S3 Bucket

I have the same needs and created the following function that download recursively the files. The directories are created locally only if they contain files. import boto3 import os def download_dir(client, resource, dist, local=”/tmp”, bucket=”your_bucket”): paginator = client.get_paginator(‘list_objects’) for result in paginator.paginate(Bucket=bucket, Delimiter=”https://stackoverflow.com/”, Prefix=dist): if result.get(‘CommonPrefixes’) is not None: for subdir in result.get(‘CommonPrefixes’): download_dir(client, resource, … Read more

Amazon S3 direct file upload from client browser – private key disclosure

I think what you want is Browser-Based Uploads Using POST. Basically, you do need server-side code, but all it does is generate signed policies. Once the client-side code has the signed policy, it can upload using POST directly to S3 without the data going through your server. Here’s the official doc links: Diagram: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingHTTPPOST.html Example … Read more

Amazon S3 – How to fix ‘The request signature we calculated does not match the signature’ error?

After two days of debugging, I finally discovered the problem… The key I was assigning to the object started with a period i.e. ..\images\ABC.jpg, and this caused the error to occur. I wish the API provides more meaningful and relevant error message, alas, I hope this will help someone else out there!

how to upload multiple images to a blog post in django

You’ll just need two models. One for the Post and the other would be for the Images. Your image model would have a foreignkey to the Post model: from django.db import models from django.contrib.auth.models import User from django.template.defaultfilters import slugify class Post(models.Model): user = models.ForeignKey(User) title = models.CharField(max_length=128) body = models.CharField(max_length=400) def get_image_filename(instance, filename): title … Read more