mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Adding google drive plugin as a fallback for url plugin
Summary: When importing from url, user types a url for google spreadsheet, Grist will switch to Google Drive plugin to allow user to choose file manualy. Test Plan: Browser tests Reviewers: paulfitz, dsagal Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2945
This commit is contained in:
@@ -5,6 +5,7 @@ import {getAuthorizedUserId, getTransitiveHeaders, getUserId, isSingleUserMode,
|
||||
RequestWithLogin} from 'app/server/lib/Authorizer';
|
||||
import {expressWrap} from 'app/server/lib/expressWrap';
|
||||
import {RequestWithGrist} from 'app/server/lib/FlexServer';
|
||||
import {downloadFromGDrive, isDriveUrl} from 'app/server/lib/GoogleImport';
|
||||
import {GristServer} from 'app/server/lib/GristServer';
|
||||
import {guessExt} from 'app/server/lib/guessExt';
|
||||
import * as log from 'app/server/lib/log';
|
||||
@@ -338,11 +339,16 @@ export async function fetchURL(url: string, accessId: string|null): Promise<Uplo
|
||||
async function _fetchURL(url: string, accessId: string|null, fileName: string,
|
||||
headers?: {[key: string]: string}): Promise<UploadResult> {
|
||||
try {
|
||||
const response: FetchResponse = await Deps.fetch(url, {
|
||||
redirect: 'follow',
|
||||
follow: 10,
|
||||
headers
|
||||
});
|
||||
let response: FetchResponse;
|
||||
if (isDriveUrl(url)) {
|
||||
response = await downloadFromGDrive(url);
|
||||
} else {
|
||||
response = await Deps.fetch(url, {
|
||||
redirect: 'follow',
|
||||
follow: 10,
|
||||
headers
|
||||
});
|
||||
}
|
||||
await _checkForError(response);
|
||||
if (fileName === '') {
|
||||
const disposition = response.headers.get('content-disposition') || '';
|
||||
|
||||
Reference in New Issue
Block a user