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.
Setup required. The Google Drive button below renders disabled until you configure an API key + OAuth client ID:
- Create a project at
console.cloud.google.com, enable the Picker API.
- Create an API key (Credentials → API key).
- Create an OAuth 2.0 Client ID (Credentials → Create → OAuth client ID → Web application). Add your origin to "Authorized JavaScript origins".
- Configure the adapter before
create():
AjaxUploader.configureRemoteSource('googledrive', {
apiKey: 'YOUR_API_KEY',
clientId: 'YOUR_OAUTH_CLIENT_ID'
});
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
- User clicks the source button rendered in the uploader chrome.
- Adapter's
pick() runs — typically opens an OAuth popup + provider's native file picker.
- On select → resolves with a
RemoteFile (or array).
- Each item is handed to
uploader.importFromUrl(url, { fileName, contentType, headers }).
- 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.