NastuzziSamy / files_external_gdrive

[BETA - UNSTABLE] GDrive external storage for NextCloud
GNU Affero General Public License v3.0
78 stars 24 forks source link

Can't download Google docs #26

Closed OzymandiasTheGreat closed 5 years ago

OzymandiasTheGreat commented 6 years ago

Nextcloud version: 13.0.5 files_external_gdrive: 0.28

Cannot download Google docs through web interface, while they do show up as size 0 odt documents, clicking on them takes a very long time and eventually errors out.

Sabre\DAV\Exception\ServiceUnavailable: Could not open file
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 88: OCA\DAV\Connector\Sabre\File->get()
[internal function] Sabre\DAV\CorePlugin->httpGet(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method GET', Array)
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/www/nextcloud/apps/dav/appinfo/v1/webdav.php - line 80: Sabre\DAV\Server->exec()
/var/www/nextcloud/remote.php - line 164: require_once('/var/www/nextcl...')
{main}

This also prevents syncing Google Drive folder with the desktop client: as soon as Google doc is encountered sync is aborted. If you need additional info, do let me know.

Ngri88 commented 6 years ago

It looks like Google Docs does not save the real document file on a Google Drive. I solved this problem by adding a script to export the document file and save it to Google Drive via Google Apps Script. After that, a real file with a size other than 0 appears on the disk and it can be downloaded through the External storage support for Google Drive.

NastuzziSamy commented 5 years ago

@Ngri88 I am interested by your script ^^

dschrempf commented 5 years ago

I have encountered the same or a very similar problem.

Sabre\DAV\Exception\ServiceUnavailable Could not open file
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\ServiceUnavailable</s:exception>
<s:message>Could not open file</s:message>
</d:error>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">...</d:error>

I wanted to add (in case it was not clear from the issue header) that other file types work as expected (e.g., PDF files).

Ngri88 commented 5 years ago

@Ngri88 I am interested by your script ^^

You are welcome. I am not the author of this script, however, it works flawlessly.

function downloadXLSX() { var ssID = SpreadsheetApp.getActive().getId(); var URL = 'https://docs.google.com/spreadsheets/d/'+ssID+'/export?format=xlsx'; var blob; var response = ""; var token = ScriptApp.getOAuthToken(); // REPLACE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your Gdrive folder's ID var destination = DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

response = UrlFetchApp.fetch(URL, { headers: { 'Authorization': 'Bearer ' + token } });

blob = response.getBlob().setName('Spreadsheet_name.xlsx');// Convert the response to a blob

var file = DriveApp.createFile(blob); // Create a file with the blob and place it to Drive's folder

destination.addFile(file);

}

NastuzziSamy commented 5 years ago

It is fixed, I did a stupid mistake ;)