Skip to content

Commit

Permalink
Merge branch '4.x' into transloadit-single-assembly
Browse files Browse the repository at this point in the history
* 4.x:
  Renames & `eslint-disable react/require-default-props` removal (#5251)
  coalesce options `bucket` and `getKey` (#5169)
  @uppy/aws-s3: add `endpoint` option (#5173)
  @uppy/locales: fix `fa_IR` export (#5241)
  improve companion logging (#5250)
  Release: [email protected] (#5243)
  @uppy/core: add generic to `getPlugin` (#5247)
  docs: add 4.x migration guide (#5206)
  @uppy/transloadit: also fix outdated assembly transloadit:result (#5246)
  docs - fix typo in the url
  @uppy/core: set default for Body generic (#5244)
  Release: [email protected] (#5242)
  docs: clarify assemblyOptions for @uppy/transloadit (#5226)
  meta: Improve aws-node example readme (#4753)
  @uppy/react: remove `react:` prefix from `id` & allow `id` as a prop (#5228)
  Added translation string (it_IT) (#5237)
  docs: correct allowedMetaFields (#5227)
  @uppy/transloadit: fix transloadit:result event (#5231)
  docs: remove `extraData` note from migration guide (#5219)
  @uppy/provider-views: fix wrong font for files (#5234)
  • Loading branch information
Murderlon committed Jun 17, 2024
2 parents 75e86ea + 2ba00ec commit a939de8
Show file tree
Hide file tree
Showing 58 changed files with 1,086 additions and 760 deletions.
2 changes: 1 addition & 1 deletion BUNDLE-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Hi, thanks for trying out the bundled version of the Uppy File Uploader. You can
use this from a CDN
(`<script src="https://releases.transloadit.com/uppy/v4.0.0-beta.10/uppy.min.js"></script>`)
(`<script src="https://releases.transloadit.com/uppy/v4.0.0-beta.11/uppy.min.js"></script>`)
or bundle it with your webapp.

Note that the recommended way to use Uppy is to install it with yarn/npm and use
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ Please add your entries in this format:

In the current stage we aim to release a new version at least every month.

## 4.0.0-beta.11

Released: 2024-06-11

| Package | Version | Package | Version |
| -------------------- | ------------- | -------------------- | ------------- |
| @uppy/aws-s3 | 4.0.0-beta.6 | @uppy/react | 4.0.0-beta.6 |
| @uppy/locales | 4.0.0-beta.3 | @uppy/transloadit | 4.0.0-beta.8 |
| @uppy/provider-views | 4.0.0-beta.8 | uppy | 4.0.0-beta.11 |

- docs: clarify assemblyOptions for @uppy/transloadit (Merlijn Vos / #5226)
- @uppy/react: remove `react:` prefix from `id` & allow `id` as a prop (Merlijn Vos / #5228)
- docs: correct allowedMetaFields (Merlijn Vos / #5227)
- docs: remove `extraData` note from migration guide (Mikael Finstad / #5219)
- meta: fix AWS test suite (Antoine du Hamel / #5229)


## 4.0.0-beta.10

Released: 2024-06-04
Expand Down Expand Up @@ -420,6 +437,21 @@ Released: 2024-03-28
- @uppy/vue: [v4.x] remove manual types (Antoine du Hamel / #4803)
- meta: prepare release workflow for beta versions (Antoine du Hamel)

## 3.26.1

Released: 2024-06-11

| Package | Version | Package | Version |
| -------------------- | ------- | -------------------- | ------- |
| @uppy/locales | 3.5.4 | @uppy/transloadit | 3.7.1 |
| @uppy/provider-views | 3.12.1 | uppy | 3.26.1 |

- meta: Improve aws-node example readme (Artur Paikin / #4753)
- @uppy/locales: Added translation string (it_IT) (Samuel / #5237)
- @uppy/transloadit: fix transloadit:result event (Merlijn Vos / #5231)
- @uppy/provider-views: fix wrong font for files (Merlijn Vos / #5234)


## 3.26.0

Released: 2024-06-04
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ npm install @uppy/core @uppy/dashboard @uppy/tus
```

Add CSS
[uppy.min.css](https://releases.transloadit.com/uppy/v4.0.0-beta.10/uppy.min.css),
[uppy.min.css](https://releases.transloadit.com/uppy/v4.0.0-beta.11/uppy.min.css),
either to your HTML page’s `<head>` or include in JS, if your bundler of choice
supports it.

Expand All @@ -94,7 +94,7 @@ object.
```html
<!-- 1. Add CSS to `<head>` -->
<link
href="https://releases.transloadit.com/uppy/v4.0.0-beta.10/uppy.min.css"
href="https://releases.transloadit.com/uppy/v4.0.0-beta.11/uppy.min.css"
rel="stylesheet"
/>

Expand All @@ -105,7 +105,7 @@ object.
Uppy,
Dashboard,
Tus,
} from 'https://releases.transloadit.com/uppy/v4.0.0-beta.10/uppy.min.mjs'
} from 'https://releases.transloadit.com/uppy/v4.0.0-beta.11/uppy.min.mjs'
const uppy = new Uppy()
uppy.use(Dashboard, { target: '#files-drag-drop' })
Expand Down
29 changes: 13 additions & 16 deletions docs/companion.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const options = {
endpoint: 'https://{service}.{region}.amazonaws.com',
conditions: [],
useAccelerateEndpoint: false,
getKey: (req, filename) => `${crypto.randomUUID()}-${filename}`,
getKey: ({ filename }) => `${crypto.randomUUID()}-${filename}`,
expires: 800, // seconds
},
allowLocalUrls: false,
Expand Down Expand Up @@ -473,13 +473,14 @@ from the AWS SDK.

The name of the bucket to store uploaded files in.

It can be function that returns the name of the bucket as a `string` and takes
the following arguments:
A `string` or function that returns the name of the bucket as a `string` and
takes one argument which is an object with the following properties:

- [`http.IncomingMessage`][], the HTTP request (will be `null` for remote
uploads)
- metadata provided by the user for the file (will be `undefined` for local
uploads)
- `filename`, the original name of the uploaded file;
- `metadata` provided by the user for the file (will only be provided during the
initial calls for each uploaded files, otherwise it will be `undefined`).
- `req`, Express.js `Request` object. Do not use any Companion internals from
the req object, as these might change in any minor version of Companion.

##### `s3.region` `COMPANION_AWS_REGION`

Expand Down Expand Up @@ -508,18 +509,16 @@ expected, please
[open an issue on the Uppy repository](https://github.com/transloadit/uppy/issues/new)
so we can document it here.

##### `s3.getKey(req, filename, metadata)`
##### `s3.getKey({ filename, metadata, req })`

Get the key name for a file. The key is the file path to which the file will be
uploaded in your bucket. This option should be a function receiving three
arguments:

- `req` [`http.IncomingMessage`][], the HTTP request, for _regular_ S3 uploads
using the `@uppy/aws-s3` plugin. This parameter is _not_ available for
multipart uploads using the `@uppy/aws-s3` or `@uppy/aws-s3-multipart`
plugins. This parameter is `null` for remote uploads.
- `filename`, the original name of the uploaded file;
- `metadata`, user-provided metadata for the file.
- `req`, Express.js `Request` object. Do not use any Companion internals from
the req object, as these might change in any minor version of Companion.

This function should return a string `key`. The `req` parameter can be used to
upload to a user-specific folder in your bucket, for example:
Expand All @@ -530,7 +529,7 @@ app.use(
uppy.app({
providerOptions: {
s3: {
getKey: (req, filename, metadata) => `${req.user.id}/${filename}`,
getKey: ({ req, filename, metadata }) => `${req.user.id}/${filename}`,
/* auth options */
},
},
Expand All @@ -546,7 +545,7 @@ app.use(
uppy.app({
providerOptions: {
s3: {
getKey: (req, filename, metadata) => filename,
getKey: ({ filename, metadata }) => filename,
},
},
}),
Expand Down Expand Up @@ -909,8 +908,6 @@ This would get the Companion instance running on `http://localhost:3020`. It
uses [`node --watch`](https://nodejs.org/api/cli.html#--watch) so it will
automatically restart when files are changed.

[`http.incomingmessage`]:
https://nodejs.org/api/http.html#class-httpincomingmessage
[box]: /docs/box
[dropbox]: /docs/dropbox
[facebook]: /docs/facebook
Expand Down
172 changes: 166 additions & 6 deletions docs/guides/migration-guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

These cover all the major Uppy versions and how to migrate to them.

## Migrate from Uppy 3.x to 4.x

### Companion
## Migrate from Companion 4.x to 5.x

- Node.js `>=18.20.0` is now required.
- `COMPANION_REDIS_EXPRESS_SESSION_PREFIX` now defaults to `companion-session:`
(before `sess:`). To revert keep backwards compatibility, set the environment
variable `COMPANION_REDIS_EXPRESS_SESSION_PREFIX=sess:`.
- The URL endpoint (used by the `Url`/`Link` plugin) is now turned off by
default and must be explicitly enabled with
`COMPANION_ENABLE_URL_ENDPOINT=true` or `enableUrlEndpoint: true`.
- The option `getKey(req, filename, metadata)` has changed signature to
`getKey({ filename, metadata, req })`.
- The option `bucket(req, metadata)` has changed signature to
`bucketOrFn({ req, metadata, filename })`.
- Custom provider breaking changes. If you have not implemented a custom
provider, you should not be affected.
- The static `getExtraConfig` property has been renamed to
`getExtraGrantConfig`.
- The static `authProvider` property has been renamed to `oauthProvider`.
- Endpoint `GET /s3/params` now returns `{ method: "POST" }` instead of
`{ method: "post" }`. This will not affect most people.
- The Companion [`error` event](https://uppy.io/docs/companion/#events) now no
longer includes `extraData` inside the `payload.error` property. `extraData`
is (and was also before) included in the `payload`.
- `access-control-allow-headers` is no longer included in
`Access-Control-Expose-Headers`, and `uppy-versions` is no longer an allowed
header. We are not aware of any issues this might cause.
Expand All @@ -35,6 +35,14 @@ These cover all the major Uppy versions and how to migrate to them.

### `@uppy/companion-client`

:::info

Unless you built a custom provider, you don’t use `@uppy/companion-client`
directly but through provider plugins such as `@uppy/google-drive`. In which
case you don’t have to do anything.

:::

- `supportsRefreshToken` now defaults to `false` instead of `true`. If you have
implemented a custom provider, this might affect you.
- `Socket` class is no longer in use and has been removed. Unless you used this
Expand All @@ -45,6 +53,158 @@ These cover all the major Uppy versions and how to migrate to them.
the third argument. Instead, pass `{ skipPostResponse: true | false }`. This
won’t affect you unless you’ve been using `RequestClient`.

## Migrate from Uppy 3.x to 4.x

### TypeScript rewrite

Almost all plugins have been completely rewritten in TypeScript! This means you
may run into type error all over the place, but the types now accurately show
Uppy’s state and files.

There are too many small changes to cover, so you have to upgrade and see where
TypeScript complains.

One important thing to note are the new generics on `@uppy/core`.

<!-- eslint-disable @typescript-eslint/no-unused-vars -->

```ts
import Uppy from '@uppy/core';
// xhr-upload is for uploading to your own backend.
import XHRUpload from '@uppy/xhr-upload';

// Your own metadata on files
type Meta = { myCustomMetadata: string };
// The response from your server
type Body = { someThingMyBackendReturns: string };

const uppy = new Uppy<Meta, Body>().use(XHRUpload, {
endpoint: '/upload',
});

const id = uppy.addFile({
name: 'example.jpg',
data: new Blob(),
meta: { myCustomMetadata: 'foo' },
});

// This is now typed
const { myCustomMetadata } = uppy.getFile(id).meta;

await uppy.upload();

// This is strictly typed too
const { someThingMyBackendReturns } = uppy.getFile(id).response;
```

### `@uppy/aws-s3` and `@uppy/aws-s3-multipart`

- `@uppy/aws-s3` and `@uppy/aws-s3-multipart` have been combined into a single
plugin. You should now only use `@uppy/aws-s3` with the new option,
[`shouldUseMultipart()`](/docs/aws-s3-multipart/#shouldusemultipartfile), to
allow you to switch between regular and multipart uploads. You can read more
about this in the
[plugin docs](https://uppy.io/docs/aws-s3-multipart/#when-should-i-use-it).
- Remove deprecated `prepareUploadParts` option.
- Companion’s options (`companionUrl`, `companionHeaders`, and
`companionCookieRules`) are renamed to more generic names (`endpoint`,
`headers`, and `cookieRules`).

Using Companion with the `@uppy/aws-s3` plugin only makes sense if you already
need Companion for remote providers (such as Google Drive). When using your
own backend, you can let Uppy do all the heavy lifting on the client which it
would normally do for Companion, so you don’t have to implement that yourself.

As long as you return the JSON for the expected endpoints (see our
[server example](https://github.com/transloadit/uppy/blob/main/examples/aws-nodejs/index.js)),
you only need to set `endpoint`.

If you are using Companion, rename the options. If you have a lot of
client-side complexity (`createMultipartUpload`, `signPart`, etc), consider
letting Uppy do this for you.

### `@uppy/core`

- The `close()` method has been renamed to `destroy()` to more accurately
reflect you can not recover from it without creating a new `Uppy` instance.
- The `clearUploadedFiles()` method has been renamed to `clear()` as a
convenience method to clear all the state. This can be useful when a user
navigates away and you want to clear the state on success.
- `bytesUploaded`, in `file.progress.bytesUploaded`, is now always a `boolean`,
instead of a `boolean` or `number`.

### `@uppy/xhr-upload`

Before the plugin had the options `getResponseData`, `getResponseError`,
`validateStatus` and `responseUrlFieldName`. These were inflexible and too
specific. Now we have hooks similar to `@uppy/tus`:

- `onBeforeRequest` to manipulate the request before it is sent.
- `shouldRetry` to determine if a request should be retried. By default 3
retries with exponential backoff. After three attempts it will throw an error,
regardless of whether you returned `true`.
- `onAfterResponse` called after a successful response but before Uppy resolves
the upload.

Checkout the [docs](/docs/xhr-upload/) for more info.

### `@uppy/transloadit`

The options `signature`, `params`, `fields`, and `getAssemblyOptions` have been
removed in favor of [`assemblyOptions`](/docs/transloadit/#assemblyoptions),
which can be an object or an (async) function returning an object.

When using `assemblyOptions()` as a function, it is now called only once for all
files, instead of per file. Before `@uppy/transloadit` was trying to be too
smart, creating multiple assemblies in which each assembly has files with
identical `fields`. This was done so you can use `fields` dynamically in your
template per file, instead of per assembly.

Now we sent all metadata of a file inside the tus upload (which
`@uppy/transloadit` uses under the hood) and make it accessible in your
Transloadit template as `file_user_meta`. You should use `fields` for global
values in your template and `file_user_meta` for per file values.

Another benefit of running `assemblyOptions()` only once, is that when
generating a
[secret](https://transloadit.com/docs/topics/signature-authentication/) on your
server (which you should), a network request is made only once for all files,
instead of per file.

### CDN

- We no longer build and serve the legacy build, made for IE11, on our CDN.

### Miscellaneous

- All uploaders plugins now consistently use
[`allowedMetaFields`](/docs/xhr-upload/#allowedmetafields). Before there were
inconsistencies between plugins.
- All plugin `titles` (what you see in the Dashboard when you open a plugin) are
now set from the `locale` option. See the
[docs](/docs/locales/#overriding-locale-strings-for-a-specific-plugin) on how
to overide a string.

### `@uppy/angular`

- Upgrade to Angular 18.x (17.x is still supported too) and to TS 5.4

### `@uppy/react`

- Remove deprecated `useUppy` & reintroduce [`useUppyState`](docs/react/#hooks)
- You can no longer set `inline` on the `Dashboard` component, use `Dashboard`
or `DashboardModal` components respectively.

### `@uppy/svelte`

- Make Svelte 5 the peer dependency
- Remove UMD output

### `@uppy/vue`

- Migrate to Composition API with TypeScript & drop Vue 2 support
- Drop Vue 2 support

## Migrate from Robodog to Uppy plugins

Uppy is flexible and extensible through plugins. But the integration code could
Expand Down
Loading

0 comments on commit a939de8

Please sign in to comment.