rajdes
Posts: 10
Joined: Thu Jul 12, 2018 1:32 pm

how to use boto

Sat Jul 14, 2018 2:15 pm

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

User avatar
B.Goode
Posts: 9220
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: boto

Sat Jul 14, 2018 8:40 pm

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?

rajdes
Posts: 10
Joined: Thu Jul 12, 2018 1:32 pm

Re: how to use boto

Sun Jul 15, 2018 3:27 am

Yes I'm test running the code before runningi it on pi

User avatar
The Traveler
Posts: 363
Joined: Sat Oct 21, 2017 3:48 pm

Re: how to use boto

Sun Jul 15, 2018 4:27 am

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.
Retired IT professional, C programmer and "beardie weirdie".
RPi interests: Developing an Infinite Improbability Drive
“Thinking outside of the box allows you to get rewards outside of your reach.” Matshona Dhliwayo

rajdes
Posts: 10
Joined: Thu Jul 12, 2018 1:32 pm

Re: how to use boto

Mon Jul 16, 2018 2:12 pm

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..

User avatar
The Traveler
Posts: 363
Joined: Sat Oct 21, 2017 3:48 pm

Re: how to use boto

Mon Jul 16, 2018 2:36 pm

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.
Retired IT professional, C programmer and "beardie weirdie".
RPi interests: Developing an Infinite Improbability Drive
“Thinking outside of the box allows you to get rewards outside of your reach.” Matshona Dhliwayo

User avatar
B.Goode
Posts: 9220
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: how to use boto

Mon Jul 16, 2018 3:32 pm

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

Return to “Python”