Skip to content

examples/gettingData.py: Problem writing large files  #59

@C14L

Description

@C14L

Possibly a bug in the "gettingData.py" example, when writing large files with more than one obj in chunk['ObjectList'].

objectStream = open(objectNameToDestinationPathMap[obj['Name']], "wb")

Opening the target file with "wb" would truncate it, before seek() moves the pointer to the write position. The result is a file that contains only NUL bytes except for the last obj block written.

A fix would be to open the file in "r+b" more, that is both seek-able and write-able without truncating.

pathlib.Path(objectNameToDestinationPathMap[obj['Name']]).touch()  # ensure file exists
objectStream = open(objectNameToDestinationPathMap[obj['Name']], "r+b")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions