Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
Download specific folder and all of its files recursively from S3 bitbucket using boto

I know how to download files recursively using aws cli

aws s3 cp {s3Directory} {localDirectory} --recursive

But i want to use Python Boto and below is my code. I want to download folders and all of its files ('Daily/2017/02/15/') from bucket 'news-live'. When i execute below command, all folders created but there is no file downloaded.

def main():
DOWNLOAD_LOCATION_PATH = "/Users/test/"
BUCKET_NAME = 'news-live'
conn  = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_ACCESS_SECRET_KEY)
bucket = conn.get_bucket(BUCKET_NAME)

#goto through the list of files
bucket_list = bucket.list('Daily/2017/02/15/')

for l in bucket_list:
    key_string = str(l.key)
    print("bucket key", l.key)
    s3_path = DOWNLOAD_LOCATION_PATH + key_string
    try:
        print ("Current File is ", s3_path)
        l.get_contents_to_filename(s3_path)
    except (OSError,S3ResponseError) as e:
        pass
        # check if the file has been downloaded locally  
        if not os.path.exists(s3_path):
            try:
                os.makedirs(s3_path)
            except OSError as exc:
                # let guard againts race conditions
                import errno
                if exc.errno != errno.EEXIST:
                    raise

I don't know how to get this work.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda