0

I trying write .zip file, what i getting from HTTP

decode data from base 64:

dataFile = base64.b64decode(b64DataString)

make zipfile from bytes:

zf = zipfile.ZipFile(io.BytesIO(dataFile), "w")

trying to write my .zip file:

zf.write('C:\temp\file.zip')

and here, on "write('C:\temp\file.zip')" i allways get "OSError". What i am doing wrong?

dark
  • 33
  • 1
  • 6

1 Answers1

0

Based on previous issues, there're a couple of ways to can provide a path to write method:

  • Escape dashes, so it'll look as 'C:\\temp\\file.zip'
  • Use "raw" form, so it'll look as r'C:\temp\file.zip'
  • Use pathlib (possibly a best solution, because cross-platform) so it'll look as:
import pathlib
pathlib.Path('C:/temp/file.zip')
sortas
  • 1,527
  • 3
  • 20
  • 29