I've been trying to generate a word document via HTML forms, using python-docx and BeautifulSoup 4. The only problem is when the user copy some Base64 images (URL images work fine). When testing locally, the program works fine, on PythonAnywhere, the error "File name too long" appears.
I'm a novice at python and it's my first time uploading in python anywhere.
Here's the code:
def convert_image(type, img, doc):
if type == 1:
# URL
img_bytes = requests.get(img).content
else:
# Base64
img_bytes = base64.b64decode(img)
image = io.BytesIO(img_bytes)
document = doc
pic = document.add_picture(image)
if pic.width > Inches(5):
DownloadView.scale_picture(pic, Inches(5))
And yeah, the Base64 string is HUGE.
What can I do to solve this error or process the data in a better way?