-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
3,526 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.