I have a byte string returned from API and store in response.content
With small content, I can save it into a file with no problem using the following code
with open(save_path, 'wb') as save_file:
save_file.write(response.content)
But for the larger file, it will cause Memory Error, So I tried not to read the content all at once, by using this code
with open(save_path, 'wb') as save_file:
for x in response.content:
save_file.write(bytes(x)) #the x from iteration seem to be converted to int so I convert it back
But the method above seems to alternate the content because it doesn't compatible with another library anymore (In my when Laspy try to read the saved file, laspy.util.LaspyException: Invalid format: h0.0
error appears)
How can I do it?