Page 1 of 1

how to use boto

Posted: Sat Jul 14, 2018 2:15 pm
by rajdes
How to use boto
How to upload multiple images from folder to aws at same time can store all your images in one particular folder and then use this kind of python script to upload all images found in your folder :
But the problem is it does not work.....help plz

Code: Select all

import os
import boto3

s3 = boto3.resource('s3')

directory_in_str="E:\\rekog\\hold"   # change directory path to your images folder

directory = os.fsencode(directory_in_str)

for file in os.listdir(directory):
    filename = os.fsdecode(file)
    if filename.endswith(".jpeg") or filename.endswith(".jpg") or filename.endswith(".png"):

        strg=directory_in_str+'\\'+filename
        print(strg)     
        file = open(strg,'rb')
        object = s3.Object('bucketname',filename)
        object.put(Body=file,ContentType='image/jpeg')

    else:
        continue

Re: boto

Posted: Sat Jul 14, 2018 8:40 pm
by B.Goode
But the problem is it does not work.....
Nor does my crystal ball!



But...

Code: Select all

directory_in_str="E:\\rekog\\hold" 
Does that mean you are running this script on a Microsoft Windows system?

Re: how to use boto

Posted: Sun Jul 15, 2018 3:27 am
by rajdes
Yes I'm test running the code before runningi it on pi

Re: how to use boto

Posted: Sun Jul 15, 2018 4:27 am
by The Traveler
But the problem is it does not work.....help plz
Error output or log?

If you're going to copy and paste code written by someone else, you should at least provide the error log output so others can fix it for you.

Re: how to use boto

Posted: Mon Jul 16, 2018 2:12 pm
by rajdes
For being true I'm immature I have no idea about coding in python I'm looking at scripts and tryingt to figure out..without any proper resources..if anyone is interested to help please I would b grateful of u all..

Re: how to use boto

Posted: Mon Jul 16, 2018 2:36 pm
by The Traveler
if anyone is interested to help please I would b grateful of u all..
Start here: https://www.python.org/about/gettingstarted/ and learn the basics at least. There are a huge number of tutorials and information resources on the Internet for you to use. Asking for someone to solve your problem for you teaches you nothing otherwise.

Re: how to use boto

Posted: Mon Jul 16, 2018 3:32 pm
by B.Goode
I have no idea about coding in python I'm looking at scripts and tryingt to figure out..without any proper resources..if anyone is interested to help please I would b grateful of u all..

https://www.raspberrypi.org/magpi/learn ... ng-python/

https://www.raspberrypi.org/magpi/best- ... ogramming/

https://www.raspberrypi.org/documentati ... /README.md

https://projects.raspberrypi.org/en/pro ... 5B%5D=%201