Skip to content

Copiyng and decompressing huge files on the fly #757

@almartinez123

Description

@almartinez123

I am trying to copy an OS image file, image.raw.gz from web server (http://server/image.raw.gz) to an unzipped destination in s3 image.raw (s3://bucket/folder/image.raw)

The process seems to work but it consumes a lot of memory.

How can I make it use less memory to perform the copy "on the fly"?

i tried to do it by declaring a buffer at 1024 but it didn't work

the function is like:

def copy_files_to_bucket(file_urls, bucket, prefix):
    for file_url in file_urls:
        file=os.path.basename(file_url)
        print ("copy " + file_url + " to " + bucket + prefix + file)
        with open(file_url, 'rb', transport_params=dict(buffer_size=1024)) as fin:
            with open("s3://" + bucket +"/" + prefix + "image.raw", 'bw', encoding=None, transport_params=dict(buffer_size=1024)) as fout:
                for line in fin
                    fout.write(line)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions