Google Drive API v3 : there isn't any way to get a download url for a google document?

前端 未结 2 1825
感动是毒
感动是毒 2021-01-01 04:24

The Google Drive API v2 to v3 migration guide says:

The exportLinks field has been removed from files. To export Google Documents, use the files.expor

相关标签:
2条回答
  • 2021-01-01 05:07

    I think you're placing too much emphasis on the word "method".

    There is still a link to export a file, it's https://www.googleapis.com/drive/v3/files/fileIdxxxxx/export&mimeType=xxxxx/xxxxx. Make sure you URL encode the mime type.

    Eg

    https://www.googleapis.com/drive/v3/files/1fGBQ81haNU_nEiC5GITZD3bxT0ppL2LHg-C0ubD4Q_s/export?mimeType=text/csv&access_token=ya29.Gmo0BMvO-pVEPKsiD9j4D-NZVGE91MChRvwOcBSg3cTHt5uAClf-jFxcovQScbO2QQhwHS95eSGW1eQQcK5G1UQ6oI4BFEJJkntEBkgriZ14GbHuvpDL7LT2pKA--WiPuNoDDIuZMm5lWtlr
    

    These links form part of the API, so the expectation is that you've written a client that sends authenticated requests, and deals with the response data. This explains why, if you simply paste the link into a browser without an access_token, it will fail. It also explains why the filename is export, ie. it isn't intended that your client would ever use a filename, but rather it should receive the data as a stream. This SO answer discusses the situation in more detail How to set name of file downloaded from browser?

    0 讨论(0)
  • 2021-01-01 05:22

    Once you query for your file by id you can use the function getWebContentLink() to get the download link of the file (eg. $file->getWebContentLink() ).

    0 讨论(0)
提交回复
热议问题