Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google photos #5061

Merged
merged 34 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5f6af38
add google photos frontend
mifi Mar 19, 2024
62312be
implement google photos
mifi Apr 8, 2024
f27b1f1
merge main
mifi Apr 8, 2024
6d94531
Merge branch 'main' into google-photos
mifi Apr 12, 2024
bf2a494
separate virtualList from loadAllFiles
mifi Apr 12, 2024
11dfff4
convert virtuallist to TS
mifi Apr 12, 2024
17d3e91
add missing file
mifi Apr 12, 2024
759ee74
Merge branch 'main' of https://github.com/transloadit/uppy
aduh95 Apr 16, 2024
702ed84
document google photos
mifi Apr 12, 2024
ca78a48
lint
aduh95 Apr 16, 2024
94f294e
prettier
mifi Apr 22, 2024
63fdbd7
Merge branch 'main' into google-photos
mifi Apr 22, 2024
339e835
Merge branch 'main' into google-photos
mifi Apr 29, 2024
67f6d0d
merge main
mifi May 5, 2024
701f2eb
run format
mifi May 5, 2024
fdc1662
fix lint
mifi May 5, 2024
d0763f1
implement user info
mifi May 5, 2024
aa09ad0
Merge branch 'main' into google-photos
mifi May 8, 2024
f65edd7
fix tests
mifi May 8, 2024
7792dcc
fix codesandbox
mifi May 9, 2024
345383e
remove accidental js file
mifi May 9, 2024
e8429f7
fix test
mifi May 9, 2024
cf2025d
fix ts
mifi May 9, 2024
0dba1bb
fix ts
mifi May 9, 2024
0c21a5e
fix ts
mifi May 9, 2024
08beacc
don't use inheritance
mifi May 13, 2024
371a7e2
remove GooglePhotosProviderViews
mifi May 13, 2024
03b1d95
git merge main
mifi Jun 12, 2024
503203b
use folder icon for albums
mifi Jun 12, 2024
eb18350
fix test
mifi Jun 12, 2024
b19ae3a
add unnamed
mifi Jun 13, 2024
4983475
Apply suggestions from code review
mifi Jun 13, 2024
5d331b9
reverse virtuallist refactor
mifi Jun 17, 2024
7c8ffa0
Update packages/@uppy/companion/src/server/provider/google/drive/inde…
mifi Jun 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ module.exports = {
'packages/@uppy/form/src/**/*.js',
'packages/@uppy/golden-retriever/src/**/*.js',
'packages/@uppy/google-drive/src/**/*.js',
'packages/@uppy/google-photos/src/**/*.js',
'packages/@uppy/image-editor/src/**/*.js',
'packages/@uppy/informer/src/**/*.js',
'packages/@uppy/instagram/src/**/*.js',
Expand Down
25 changes: 14 additions & 11 deletions docs/companion.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ OAuth.
## When should I use it?

If you want to let users download files from [Box][], [Dropbox][], [Facebook][],
[Google Drive][googledrive], [Instagram][], [OneDrive][], [Unsplash][], [Import
from URL][url], or [Zoom][] — you need Companion.
[Google Drive][googledrive], [Google Photos][googlephotos], [Instagram][],
[OneDrive][], [Unsplash][], [Import from URL][url], or [Zoom][] — you need
Companion.

Companion supports the same [uploaders](/docs/guides/choosing-uploader) as Uppy:
[Tus](/docs/tus), [AWS S3](/docs/aws-s3), and [regular multipart](/docs/tus).
Expand Down Expand Up @@ -435,15 +436,16 @@ the secret, nothing else.

:::

| Service | Key | Environment variables |
| ------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Box | `box` | `COMPANION_BOX_KEY`, `COMPANION_BOX_SECRET`, `COMPANION_BOX_SECRET_FILE` |
| Dropbox | `dropbox` | `COMPANION_DROPBOX_KEY`, `COMPANION_DROPBOX_SECRET`, `COMPANION_DROPBOX_SECRET_FILE` |
| Facebook | `facebook` | `COMPANION_FACEBOOK_KEY`, `COMPANION_FACEBOOK_SECRET`, `COMPANION_FACEBOOK_SECRET_FILE` |
| Google Drive | `drive` | `COMPANION_GOOGLE_KEY`, `COMPANION_GOOGLE_SECRET`, `COMPANION_GOOGLE_SECRET_FILE` |
| Instagram | `instagram` | `COMPANION_INSTAGRAM_KEY`, `COMPANION_INSTAGRAM_SECRET`, `COMPANION_INSTAGRAM_SECRET_FILE` |
| OneDrive | `onedrive` | `COMPANION_ONEDRIVE_KEY`, `COMPANION_ONEDRIVE_SECRET`, `COMPANION_ONEDRIVE_SECRET_FILE`, `COMPANION_ONEDRIVE_DOMAIN_VALIDATION` (Settings this variable to `true` enables a route that can be used to validate your app with OneDrive) |
| Zoom | `zoom` | `COMPANION_ZOOM_KEY`, `COMPANION_ZOOM_SECRET`, `COMPANION_ZOOM_SECRET_FILE`, `COMPANION_ZOOM_VERIFICATION_TOKEN` |
| Service | Key | Environment variables |
| ------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Box | `box` | `COMPANION_BOX_KEY`, `COMPANION_BOX_SECRET`, `COMPANION_BOX_SECRET_FILE` |
| Dropbox | `dropbox` | `COMPANION_DROPBOX_KEY`, `COMPANION_DROPBOX_SECRET`, `COMPANION_DROPBOX_SECRET_FILE` |
| Facebook | `facebook` | `COMPANION_FACEBOOK_KEY`, `COMPANION_FACEBOOK_SECRET`, `COMPANION_FACEBOOK_SECRET_FILE` |
| Google Drive | `drive` | `COMPANION_GOOGLE_KEY`, `COMPANION_GOOGLE_SECRET`, `COMPANION_GOOGLE_SECRET_FILE` |
| Google Photos | `googlephotos` | `COMPANION_GOOGLE_KEY`, `COMPANION_GOOGLE_SECRET`, `COMPANION_GOOGLE_SECRET_FILE` |
| Instagram | `instagram` | `COMPANION_INSTAGRAM_KEY`, `COMPANION_INSTAGRAM_SECRET`, `COMPANION_INSTAGRAM_SECRET_FILE` |
| OneDrive | `onedrive` | `COMPANION_ONEDRIVE_KEY`, `COMPANION_ONEDRIVE_SECRET`, `COMPANION_ONEDRIVE_SECRET_FILE`, `COMPANION_ONEDRIVE_DOMAIN_VALIDATION` (Settings this variable to `true` enables a route that can be used to validate your app with OneDrive) |
| Zoom | `zoom` | `COMPANION_ZOOM_KEY`, `COMPANION_ZOOM_SECRET`, `COMPANION_ZOOM_SECRET_FILE`, `COMPANION_ZOOM_VERIFICATION_TOKEN` |

#### `s3`

Expand Down Expand Up @@ -918,6 +920,7 @@ when files are changed.
[dropbox]: /docs/dropbox
[facebook]: /docs/facebook
[googledrive]: /docs/google-drive
[googlephotos]: /docs/google-photos
[instagram]: /docs/instagram
[onedrive]: /docs/onedrive
[unsplash]: /docs/unsplash
Expand Down
17 changes: 9 additions & 8 deletions docs/guides/migration-guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,14 +626,15 @@ to:

<div class="table-responsive">

| Provider | New Redirect URI |
| ------------ | ------------------------------------------------- |
| Dropbox | `https://$COMPANION_HOST_NAME/dropbox/redirect` |
| Google Drive | `https://$COMPANION_HOST_NAME/drive/redirect` |
| OneDrive | `https://$COMPANION_HOST_NAME/onedrive/redirect` |
| Box | `https://$YOUR_COMPANION_HOST_NAME/box/redirect` |
| Facebook | `https://$COMPANION_HOST_NAME/facebook/redirect` |
| Instagram | `https://$COMPANION_HOST_NAME/instagram/redirect` |
| Provider | New Redirect URI |
| ------------- | ---------------------------------------------------- |
| Dropbox | `https://$COMPANION_HOST_NAME/dropbox/redirect` |
| Google Drive | `https://$COMPANION_HOST_NAME/drive/redirect` |
| Google Photos | `https://$COMPANION_HOST_NAME/googlephotos/redirect` |
| OneDrive | `https://$COMPANION_HOST_NAME/onedrive/redirect` |
| Box | `https://$YOUR_COMPANION_HOST_NAME/box/redirect` |
| Facebook | `https://$COMPANION_HOST_NAME/facebook/redirect` |
| Instagram | `https://$COMPANION_HOST_NAME/instagram/redirect` |

</div>

Expand Down
16 changes: 8 additions & 8 deletions docs/sources/companion-plugins/google-drive.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UppyCdnExample from '/src/components/UppyCdnExample';
# Google Drive

The `@uppy/google-drive` plugin lets users import files from their
[Google Drive](https://www.drive.google.com) account.
[Google Drive](https://drive.google.com) account.

:::tip

Expand All @@ -22,7 +22,7 @@ The `@uppy/google-drive` plugin lets users import files from their
## When should I use this?

When you want to let users import files from their
[Google Drive](https://www.drive.google.com) account.
[Google Drive](https://drive.google.com) account.

A [Companion](/docs/companion) instance is required for the Google Drive plugin
to work. Companion handles authentication with Google Drive, downloads the
Expand Down Expand Up @@ -112,12 +112,12 @@ https://api2.transloadit.com/companion/drive/redirect

Google will give you an OAuth client ID and client secret.

Configure the Google Drive key and secret in Companion. With the standalone
Companion server, specify environment variables:
Configure the Google key and secret in Companion. With the standalone Companion
server, specify environment variables:

```shell
export COMPANION_GOOGLE_KEY="Google Drive OAuth client ID"
export COMPANION_GOOGLE_SECRET="Google Drive OAuth client secret"
export COMPANION_GOOGLE_KEY="Google OAuth client ID"
export COMPANION_GOOGLE_SECRET="Google OAuth client secret"
```

When using the Companion Node.js API, configure these options:
Expand All @@ -126,8 +126,8 @@ When using the Companion Node.js API, configure these options:
companion.app({
providerOptions: {
drive: {
key: 'Google Drive OAuth client ID',
secret: 'Google Drive OAuth client secret',
key: 'Google OAuth client ID',
secret: 'Google OAuth client secret',
},
},
});
Expand Down
185 changes: 185 additions & 0 deletions docs/sources/companion-plugins/google-photos.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
---
slug: /google-photos
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import UppyCdnExample from '/src/components/UppyCdnExample';

# Google Photos

The `@uppy/google-photos` plugin lets users import files from their
[Google Photos](https://photos.google.com) account.

:::tip

[Try out the live example](/examples) or take it for a spin in
[StackBlitz](https://stackblitz.com/edit/vitejs-vite-zaqyaf?file=main.js).

:::

## When should I use this?

When you want to let users import files from their
[Google Photos](https://photos.google.com) account.

A [Companion](/docs/companion) instance is required for the Google Photos plugin
to work. Companion handles authentication with Google Photos, downloads the
photos/videos, and uploads them to the destination. This saves the user
bandwidth, especially helpful if they are on a mobile connection.

You can self-host Companion or get a hosted version with any
[Transloadit plan](https://transloadit.com/pricing/).

<Tabs>
<TabItem value="npm" label="NPM" default>

```shell
npm install @uppy/google-photos
```

</TabItem>

<TabItem value="yarn" label="Yarn">

```shell
yarn add @uppy/google-photos
```

</TabItem>

<TabItem value="cdn" label="CDN">
<UppyCdnExample>
{`
import { Uppy, GooglePhotos } from "{{UPPY_JS_URL}}"
const uppy = new Uppy()
uppy.use(GooglePhotos, {
// Options
})
`}
</UppyCdnExample>
</TabItem>
</Tabs>

## Use

Using Google Photos requires setup in both Uppy and Companion.

### Use in Uppy

```js {10-13} showLineNumbers
import Uppy from '@uppy/core';
import Dashboard from '@uppy/dashboard';
import GooglePhotos from '@uppy/google-photos';

import '@uppy/core/dist/style.min.css';
import '@uppy/dashboard/dist/style.min.css';

new Uppy()
.use(Dashboard, { inline: true, target: '#dashboard' })
.use(GooglePhotos, {
target: Dashboard,
companionUrl: 'https://your-companion.com',
});
```

### Use in Companion

To sign up for API keys, go to the
[Google Developer Console](https://console.developers.google.com/).

Create a project for your app if you don’t have one yet.

- On the project’s dashboard,
[enable the Google Photos API](https://developers.google.com/photos).
- [Set up OAuth authorization](https://developers.google.com/photos/library/guides/authorization).

The app page has a `"Redirect URIs"` field. Here, add:

```
https://$YOUR_COMPANION_HOST_NAME/googlephotos/redirect
```

If you are using Transloadit hosted Companion:

```
https://api2.transloadit.com/companion/googlephotos/redirect
```

Google will give you an OAuth client ID and client secret.

Configure the Google key and secret in Companion. With the standalone Companion
server, specify environment variables:

```shell
export COMPANION_GOOGLE_KEY="Google OAuth client ID"
export COMPANION_GOOGLE_SECRET="Google OAuth client secret"
```

When using the Companion Node.js API, configure these options:

```js
companion.app({
providerOptions: {
googlephotos: {
key: 'Google OAuth client ID',
secret: 'Google OAuth client secret',
},
},
});
```

## API

### Options

#### `id`

A unique identifier for this plugin (`string`, default: `'GooglePhotos'`).

#### `title`

Title / name shown in the UI, such as Dashboard tabs (`string`, default:
`'GooglePhotos'`).

#### `target`

DOM element, CSS selector, or plugin to place the drag and drop area into
(`string` or `Element`, default: `null`).

#### `companionUrl`

URL to a [Companion](/docs/companion) instance (`string`, default: `null`).

#### `companionHeaders`

Custom headers that should be sent along to [Companion](/docs/companion) on
every request (`Object`, default: `{}`).

#### `companionAllowedHosts`

The valid and authorised URL(s) from which OAuth responses should be accepted
(`string` or `RegExp` or `Array`, default: `companionUrl`).

This value can be a `string`, a `RegExp` pattern, or an `Array` of both. This is
useful when you have your [Companion](/docs/companion) running on several hosts.
Otherwise, the default value should do fine.

#### `companionCookiesRule`

This option correlates to the
[RequestCredentials value](https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials)
(`string`, default: `'same-origin'`).

This tells the plugin whether to send cookies to [Companion](/docs/companion).

#### `locale`

```js
export default {
strings: {
pluginNameGooglePhotos: 'GooglePhotos',
},
};
```
2 changes: 1 addition & 1 deletion docs/sources/companion-plugins/instagram.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ When using the Companion Node.js API, configure these options:
```js
companion.app({
providerOptions: {
drive: {
instagram: {
key: 'Instagram OAuth client ID',
secret: 'Instagram OAuth client secret',
},
Expand Down
4 changes: 2 additions & 2 deletions docs/uploader/transloadit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ uppy.on('transloadit:complete', (assembly) => {});

:::note

All [Transloadit plans](https://transloadit.com/pricing/) come with a hosted version
of Companion.
All [Transloadit plans](https://transloadit.com/pricing/) come with a hosted
version of Companion.

:::

Expand Down
2 changes: 2 additions & 0 deletions docs/user-interfaces/dashboard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ all Uppy plugins.
[Facebook](https://facebook.com).
- [`@uppy/google-drive`](/docs/google-drive) — import from
[Google Drive](https://drive.google.com).
- [`@uppy/google-photos`](/docs/google-photos) — import from
[Google Photos](https://photos.google.com).
- [`@uppy/instagram`](/docs/instagram) — import from
[Instagram](https://instagram.com).
- [`@uppy/onedrive`](/docs/onedrive) — import from
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/integration/dashboard-transloadit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describe('Dashboard with Transloadit', () => {
client_ip: null,
client_referer: null,
transloadit_client:
'uppy-core:3.2.0,uppy-transloadit:3.1.3,uppy-tus:3.1.0,uppy-dropbox:3.1.1,uppy-box:2.1.1,uppy-facebook:3.1.1,uppy-google-drive:3.1.1,uppy-instagram:3.1.1,uppy-onedrive:3.1.1,uppy-zoom:2.1.1,uppy-url:3.3.1',
'uppy-core:3.2.0,uppy-transloadit:3.1.3,uppy-tus:3.1.0,uppy-dropbox:3.1.1,uppy-box:2.1.1,uppy-facebook:3.1.1,uppy-google-drive:3.1.1,uppy-google-photos:0.0.1,uppy-instagram:3.1.1,uppy-onedrive:3.1.1,uppy-zoom:2.1.1,uppy-url:3.3.1',
start_date: new Date().toISOString(),
upload_meta_data_extracted: false,
warnings: [],
Expand Down
1 change: 1 addition & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@uppy/form": "workspace:^",
"@uppy/golden-retriever": "workspace:^",
"@uppy/google-drive": "workspace:^",
"@uppy/google-photos": "workspace:^",
"@uppy/image-editor": "workspace:^",
"@uppy/informer": "workspace:^",
"@uppy/instagram": "workspace:^",
Expand Down
1 change: 1 addition & 0 deletions examples/angular-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@uppy/core": "workspace:*",
"@uppy/drag-drop": "workspace:*",
"@uppy/google-drive": "workspace:*",
"@uppy/google-photos": "workspace:*",
"@uppy/progress-bar": "workspace:*",
"@uppy/tus": "workspace:*",
"@uppy/webcam": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/box/src/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default class Box<M extends Meta, B extends Body> extends UIPlugin<
this.view = new ProviderViews(this, {
provider: this.provider,
loadAllFiles: true,
virtualList: true,
})

const { target } = this.opts
Expand Down
Loading