I’m working on a project where I need to upload files to Google Docs using the gdata Python library. I’ve got OAuth set up and can upload most file types like .doc and .xls without issues.
However, I’m running into problems with PDF files. Even though they’re listed as supported, I can’t seem to get them to upload. I’ve tried the latest gdata version but no luck.
I’m also wondering if anyone has figured out how to upload .pptx files. I know they’re not officially supported, but I’m hoping there might be a workaround.
Has anyone here successfully uploaded PDFs to Google Docs with gdata? Any tips or tricks would be super helpful. Thanks!
hey josephk, i’ve had some luck with pdfs using gdata. make sure ur using the right MIME type (‘application/pdf’) and check file size limits. for pptx, ur best bet is prolly converting to ppt or pdf first. if all else fails, maybe look into the google drive API - its more forgiving with different file types. good luck!
I’ve encountered similar challenges with gdata and PDF uploads. One workaround that worked for me was using the Google Drive API instead. It’s more robust and handles PDFs much better. For PPTX files, I found success by first converting them to PDF format before uploading. This method preserves the presentation’s layout and is generally accepted by Google Docs.
Another tip: ensure your OAuth scope includes both ‘https://www.googleapis.com/auth/drive’ and ‘https://www.googleapis.com/auth/drive.file’. This full access sometimes resolves permission-related upload issues.
If you’re open to alternatives, consider exploring the googleapiclient library. It’s more current and offers smoother integration with Google’s services, including better support for various file types.
I’ve been in a similar situation, and I can tell you it’s definitely tricky. For PDFs, I found that the issue was often related to the content type. Make sure you’re setting it correctly to ‘application/pdf’ when uploading. Also, double-check that your PDF isn’t password-protected or corrupted.
As for PPTX files, you’re right that they’re not officially supported. What worked for me was converting them to the older PPT format before uploading. It’s not ideal, but it gets the job done. Alternatively, you could look into using the Google Drive API instead of gdata. It’s more modern and has better support for various file types.
If you’re still having trouble, you might want to consider using a different library altogether. I’ve had good experiences with PyDrive, which is a wrapper for the Google Drive API and tends to handle these file types more smoothly.