Remote sources (Google Drive, Dropbox, OneDrive, …)

Pull files straight from cloud storage — no local copy needed

AjaxUploader v5 ships a pluggable remote-source registry. Built-in: Google Drive Picker (OAuth implicit flow, no server broker). Extend via AjaxUploader.registerRemoteSource(name, source) for Dropbox, OneDrive, Box, or any custom file-portal. Each picked file's download URL flows into the existing server-side importFromUrl() pipeline — streamed through your provider, with the same NDJSON live-progress contract as URL import.

Registering a custom source
AjaxUploader.registerRemoteSource('dropbox', {
    title: 'Dropbox',
    icon:  '<svg viewBox=...>...</svg>',     // SVG markup or img URL
    ready: function () { return !!window.Dropbox; },

    pick: function (uploader) {
        return new Promise(function (resolve, reject) {
            window.Dropbox.choose({
                multiselect: true,
                linkType: 'direct',
                success: function (files) {
                    resolve(files.map(function (f) {
                        return { url: f.link, fileName: f.name, fileSize: f.bytes };
                    }));
                },
                cancel: function () { reject(new Error('cancelled')); }
            });
        });
    }
});

AjaxUploader.create('#uploader', {
    remoteSources: ['googledrive', 'dropbox']
});
RemoteFile shape returned from pick()
{
    url:          'https://www.googleapis.com/drive/v3/files/abc?alt=media',
    fileName:     'quarterly-report.pdf',
    fileSize:     2_457_600,                       // optional
    contentType:  'application/pdf',                // optional
    headers:      { 'Authorization': 'Bearer ya29...' }   // optional
}
Wire flow
  1. User clicks the source button rendered in the uploader chrome.
  2. Adapter's pick() runs — typically opens an OAuth popup + provider's native file picker.
  3. On select → resolves with a RemoteFile (or array).
  4. Each item is handed to uploader.importFromUrl(url, { fileName, contentType, headers }).
  5. The server /import-url endpoint fetches the URL (using any provided Authorization header) and streams through your IUploaderProvider with live NDJSON progress.
Built-in: Google Drive (no server broker needed)

Uses Google Picker + Identity Services. The browser opens the OAuth popup, gets an access token, passes it to Picker, then forwards the token as Authorization when the server fetches the file from Drive's REST API. The token never goes to your server — just the URL + the bearer.

Roadmap
  • Built-in Dropbox + OneDrive adapters (same pattern as Drive) — coming in 5.1.
  • Server-side broker for OAuth flows where the browser shouldn't see the token — opt-in via remoteSourcesBroker: '/api/upload/remote-sources'.
  • Per-source MIME / size filters at picker-time — partial support today via options.