Skip to content

Commit

Permalink
companion,box: Box provider implementation (#2549)
Browse files Browse the repository at this point in the history
* boilerplate for Box provider

TODO:
  - adapter
  - index
  - website/src/docs
  - tests

* Box provider implementation

- adapter
- index
- npm bufoonery
- lil' fixes

and MORE!

TODO:
- thumbnails 🤬
- tests
- docs

* Box provider: add brand icon, fix file icons

- token issues with thumbnail/logout

* Box provider: fix thumbnails, upload

- fix tokens for box
- implement `size()`
- make debug logging easier to find (bold blue)

learned:
- box needs cookie auth
- thumbnail requests come back as 202s

TODO:
- fix logout with form POST (zoom example)

* Box provider: fix logout

- add client info as formData to revoke post

TODO:
- tests cleanup
- package-lock fix
- docs

* Box provider: docs

TODO:
- tests

* Box provider: cleanup

TODO:
- tests

* fix error msg path for Box

- remove comment

* keeping up

- update ProviderViews import
- fix version string on Box package.json

* companion,box: exclude box from global module/examples while in beta

Co-authored-by: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>
  • Loading branch information
cartfisk and ifedapoolarewaju authored Nov 13, 2020
1 parent ed64523 commit 970ac8d
Show file tree
Hide file tree
Showing 40 changed files with 844 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Other things to keep in mind during release:
After a release, the demos on transloadit.com should also be updated. After updating, check that some things work locally:

- the demos in the demo section work (try one that uses an import robot, and one that you need to upload to)
- the demos on the homepage work and can import from GDrive, Insta, Dropbox
- the demos on the homepage work and can import from Google Drive, Instagram, Dropbox, etc.

If you don't have access to the transloadit.com source code ping @arturi or @goto-bus-stop and we'll pick it up. :sparkles:

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Uppy is a sleek, modular JavaScript file uploader that integrates seamlessly with any application. It’s fast, easy to use and lets you worry about more important problems than building a file uploader.

- **Fetch** files from local disk, remote URLs, Google Drive, Dropbox, Instagram or snap and record selfies with a camera
- **Fetch** files from local disk, remote URLs, Google Drive, Dropbox, Box, Instagram or snap and record selfies with a camera
- **Preview** and edit metadata with a nice interface
- **Upload** to the final destination, optionally process/encode

Expand Down Expand Up @@ -48,7 +48,7 @@ const uppy = new Uppy({ autoProceed: false })

- Lightweight, modular plugin-based architecture, easy on dependencies :zap:
- Resumable file uploads via the open [tus](https://tus.io/) standard, so large uploads survive network hiccups
- Supports picking files from: Webcam, Dropbox, Google Drive, Instagram, bypassing the user’s device where possible, syncing between servers directly via [@uppy/companion](https://uppy.io/docs/companion)
- Supports picking files from: Webcam, Dropbox, Box, Google Drive, Instagram, bypassing the user’s device where possible, syncing between servers directly via [@uppy/companion](https://uppy.io/docs/companion)
- Works great with file encoding and processing backends, such as [Transloadit](https://transloadit.com), works great without (just roll your own Apache/Nginx/Node/FFmpeg/etc backend)
- Sleek user interface :sparkles:
- Optional file recovery (after a browser crash) with [Golden Retriever](https://uppy.io/docs/golden-retriever/)
Expand Down Expand Up @@ -91,7 +91,7 @@ Alternatively, you can also use a pre-built bundle from Transloadit's CDN: Edgly

- [Uppy](https://uppy.io/docs/uppy/) — full list of options, methods and events
- [Plugins](https://uppy.io/docs/plugins/) — list of Uppy plugins and their options
- [Companion](https://uppy.io/docs/companion/) — setting up and running a Companion instance, which adds support for Instagram, Dropbox, Google Drive and remote URLs
- [Companion](https://uppy.io/docs/companion/) — setting up and running a Companion instance, which adds support for Instagram, Dropbox, Box, Google Drive and remote URLs
- [React](https://uppy.io/docs/react/) — components to integrate Uppy UI plugins with React apps
- [Architecture & Writing a Plugin](https://uppy.io/docs/writing-plugins/) — how to write a plugin for Uppy

Expand All @@ -113,6 +113,7 @@ Alternatively, you can also use a pre-built bundle from Transloadit's CDN: Edgly
- [`Webcam`](https://uppy.io/docs/webcam/) — snap and record those selfies 📷
-[`Google Drive`](https://uppy.io/docs/google-drive/) — import files from Google Drive
-[`Dropbox`](https://uppy.io/docs/dropbox/) — import files from Dropbox
-[`Box`](https://uppy.io/docs/box/) — import files from Box
-[`Instagram`](https://uppy.io/docs/instagram/) — import images and videos from Instagram
-[`Facebook`](https://uppy.io/docs/facebook/) — import images and videos from Facebook
-[`OneDrive`](https://uppy.io/docs/onedrive/) — import files from Microsoft OneDrive
Expand Down
4 changes: 2 additions & 2 deletions bin/remove-accidental-git-tags.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

# removes tags that Lerna generated, but then failed to release,
# removes tags that Lerna generated, but then failed to release,
# and is now unfortunately stuck
# usage: ./remove-tags.sh VERSION_NUMBER
# where VERSION_NUMBER is something like 0.30.0

Packages=(aws-s3 file-input react transloadit aws-s3-multipart form redux-dev-tools tus companion golden-retriever robodog url companion-client google-drive server-utils utils core informer status-bar webcam dashboard instagram store-default xhr-upload drag-drop progress-bar store-redux dropbox provider-views thumbnail-generator)
Packages=(aws-s3 file-input react transloadit aws-s3-multipart form redux-dev-tools tus companion golden-retriever robodog url companion-client google-drive server-utils utils core informer status-bar webcam dashboard instagram store-default xhr-upload drag-drop progress-bar store-redux dropbox box provider-views thumbnail-generator)
Version = $*

for i in "${Packages[@]}"
Expand Down
4 changes: 4 additions & 0 deletions env.example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
export NODE_ENV="${NODE_ENV:-development}"
export COMPANION_DROPBOX_KEY="***"
export COMPANION_DROPBOX_SECRET="***"
export COMPANION_BOX_KEY="***"
export COMPANION_BOX_SECRET="***"
export COMPANION_GOOGLE_KEY="***"
export COMPANION_GOOGLE_SECRET="***"
export COMPANION_INSTAGRAM_KEY="***"
Expand All @@ -23,6 +25,8 @@ export COMPANION_ZOOM_SECRET="***"
# travis encrypt --add GHPAGES_URL=https://secret_access_token@github.com/transloadit/uppy.git
# travis encrypt --add env.global "COMPANION_DROPBOX_KEY=${COMPANION_DROPBOX_KEY}"
# travis encrypt --add env.global "COMPANION_DROPBOX_SECRET=${COMPANION_DROPBOX_SECRET}"
# travis encrypt --add env.global "COMPANION_BOX_KEY=${COMPANION_BOX_KEY}"
# travis encrypt --add env.global "COMPANION_BOX_SECRET=${COMPANION_BOX_SECRET}"
# travis encrypt --add env.global "COMPANION_GOOGLE_KEY=${COMPANION_GOOGLE_KEY}"
# travis encrypt --add env.global "COMPANION_GOOGLE_SECRET=${COMPANION_GOOGLE_SECRET}"
# travis encrypt --add env.global "COMPANION_INSTAGRAM_KEY=${COMPANION_INSTAGRAM_KEY}"
Expand Down
2 changes: 2 additions & 0 deletions examples/dev/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Instagram = require('@uppy/instagram/src')
const Facebook = require('@uppy/facebook/src')
const OneDrive = require('@uppy/onedrive/src')
const Dropbox = require('@uppy/dropbox/src')
const Box = require('@uppy/box/src')
const GoogleDrive = require('@uppy/google-drive/src')
const Unsplash = require('@uppy/unsplash/src')
const Zoom = require('@uppy/zoom/src')
Expand Down Expand Up @@ -67,6 +68,7 @@ module.exports = () => {
.use(GoogleDrive, { target: Dashboard, companionUrl: COMPANION_URL })
.use(Instagram, { target: Dashboard, companionUrl: COMPANION_URL })
.use(Dropbox, { target: Dashboard, companionUrl: COMPANION_URL })
.use(Box, { target: Dashboard, companionUrl: COMPANION_URL })
.use(Facebook, { target: Dashboard, companionUrl: COMPANION_URL })
.use(OneDrive, { target: Dashboard, companionUrl: COMPANION_URL })
.use(Zoom, { target: Dashboard, companionUrl: COMPANION_URL })
Expand Down
10 changes: 9 additions & 1 deletion examples/uppy-with-companion/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ const uppyOptions = {
instagram: {
key: 'your instagram key',
secret: 'your instagram secret'
},
dropbox: {
key: 'your dropbox key',
secret: 'your dropbox secret'
},
box: {
key: 'your box key',
secret: 'your box secret'
}
// you can also add options for dropbox here
// you can also add options for additional providers here
},
server: {
host: 'localhost:3020',
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@uppy-example/xhr-bundle": "file:examples/xhr-bundle",
"@uppy/aws-s3": "file:packages/@uppy/aws-s3",
"@uppy/aws-s3-multipart": "file:packages/@uppy/aws-s3-multipart",
"@uppy/box": "file:packages/@uppy/box",
"@uppy/companion": "file:packages/@uppy/companion",
"@uppy/companion-client": "file:packages/@uppy/companion-client",
"@uppy/core": "file:packages/@uppy/core",
Expand Down
21 changes: 21 additions & 0 deletions packages/@uppy/box/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Transloadit

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 42 additions & 0 deletions packages/@uppy/box/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# @uppy/box

<img src="https://uppy.io/images/logos/uppy-dog-head-arrow.svg" width="120" alt="Uppy logo: a superman puppy in a pink suit" align="right">

<a href="https://www.npmjs.com/package/@uppy/box"><img src="https://img.shields.io/npm/v/@uppy/box.svg?style=flat-square"></a>
<a href="https://travis-ci.org/transloadit/uppy"><img src="https://img.shields.io/travis/transloadit/uppy/master.svg?style=flat-square" alt="Build Status"></a>

The Box plugin for Uppy lets users import files from their Box account.

A Companion instance is required for the Box plugin to work. Companion handles authentication with Box, downloads files from Box and uploads them to the destination. This saves the user bandwidth, especially helpful if they are on a mobile connection.

Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service.

## Example

```js
const Uppy = require('@uppy/core')
const Box = require('@uppy/box')

const uppy = new Uppy()
uppy.use(Box, {
// Options
})
```

## Installation

```bash
$ npm install @uppy/box
```

We recommend installing from npm and then using a module bundler such as [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/) or [Rollup.js](http://rollupjs.org/).

Alternatively, you can also use this plugin in a pre-built bundle from Transloadit's CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. See the [main Uppy documentation](https://uppy.io/docs/#Installation) for instructions.

## Documentation

Documentation for this plugin can be found on the [Uppy website](https://uppy.io/docs/box).

## License

[The MIT License](./LICENSE).
104 changes: 104 additions & 0 deletions packages/@uppy/box/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions packages/@uppy/box/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@uppy/box",
"description": "Import files from Box, into Uppy.",
"version": "1.0.0",
"license": "MIT",
"main": "lib/index.js",
"types": "types/index.d.ts",
"keywords": [
"file uploader",
"uppy",
"uppy-plugin",
"box"
],
"homepage": "https://uppy.io",
"bugs": {
"url": "https://github.com/transloadit/uppy/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/transloadit/uppy.git"
},
"dependencies": {
"@uppy/companion-client": "file:../companion-client",
"@uppy/provider-views": "file:../provider-views",
"@uppy/utils": "file:../utils",
"preact": "8.2.9"
},
"peerDependencies": {
"@uppy/core": "^1.0.0"
}
}
Loading

0 comments on commit 970ac8d

Please sign in to comment.