google-api-php-client: Cannot download a google drive file with the correct filename

I’ve been digging around on the internet for some time now for a solution to my problem. My issue is that I cannot for the life of me figure out how to download files using the API with the correct filename. So far I have not been able to solve it (but I’m really close). My solution right now is to use Drive API v2 and get a downloadUrl, but right now it is giving me a 403 error when I visit the link. That’s a whole separate issue and I won’t need help with it as I have pinpointed the cause. My main problem is that I’d rather use Drive API v3, even if not now I will eventually need to when v2 is deprecated. Drive API v3 does provide a way to download files using an authenticated request, obviously. Unfortunately these downloaded files are renamed to just the file id and nothing else. I don’t want to have my user’s manually rename the files, since most of them will probably think it’s a virus or not have a clue what to do with them. Is there a way to have it download with the correct file name, maybe via a name="file.zip" parameter or something tacked onto the request? There are other ways which I’ve found to get around this, but they either use my server bandwidth or use blobs. Neither of which I would like to use. I saw on some other Stack Overflow topic that the OP was able to download files with the correct name using the same exact method as I am. And even I found a website which is somehow able to accomplish this, albeit most likely with API v2. The website actually works and I am dumbfounded as to how they did it. Am I just unlucky, or is there a brilliant solution out there? Please, anyone, help me out with this if you can. It’s bugging me so much.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Is there any solutions for direct downloads via curl with correct Content-Disposition?