diff --git a/BUNDLE-README.md b/BUNDLE-README.md index 40f6b71940..add956bcc7 100644 --- a/BUNDLE-README.md +++ b/BUNDLE-README.md @@ -2,7 +2,7 @@ Hi, thanks for trying out the bundled version of the Uppy File Uploader. You can use this from a CDN -(``) +(``) or bundle it with your webapp. Note that the recommended way to use Uppy is to install it with yarn/npm and use diff --git a/CHANGELOG.md b/CHANGELOG.md index e81dc5ff45..b6028f9dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/README.md b/README.md index de2a387000..2f039b9820 100644 --- a/README.md +++ b/README.md @@ -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 `
` or include in JS, if your bundler of choice supports it. @@ -94,7 +94,7 @@ object. ```html @@ -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' }) diff --git a/docs/companion.md b/docs/companion.md index 742c25458a..6a8fffbf1e 100644 --- a/docs/companion.md +++ b/docs/companion.md @@ -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, @@ -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` @@ -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: @@ -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 */ }, }, @@ -546,7 +545,7 @@ app.use( uppy.app({ providerOptions: { s3: { - getKey: (req, filename, metadata) => filename, + getKey: ({ filename, metadata }) => filename, }, }, }), @@ -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 diff --git a/docs/guides/migration-guides.md b/docs/guides/migration-guides.md index 34641255b0..03694fa5ba 100644 --- a/docs/guides/migration-guides.md +++ b/docs/guides/migration-guides.md @@ -2,16 +2,19 @@ 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 @@ -19,9 +22,6 @@ These cover all the major Uppy versions and how to migrate to them. - 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. @@ -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 @@ -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`. + + + +```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().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 diff --git a/docs/uploader/aws-s3-multipart.mdx b/docs/uploader/aws-s3-multipart.mdx index 9154926f69..a21183ac72 100644 --- a/docs/uploader/aws-s3-multipart.mdx +++ b/docs/uploader/aws-s3-multipart.mdx @@ -166,7 +166,7 @@ import '@uppy/dashboard/dist/style.min.css'; const uppy = new Uppy() .use(Dashboard, { inline: true, target: 'body' }) .use(AwsS3, { - companionUrl: 'https://companion.uppy.io', + endpoint: 'https://companion.uppy.io', }); ``` @@ -215,22 +215,23 @@ uploaded. ::: -#### `companionUrl` +#### `endpoint` -URL to a [Companion](/docs/companion) instance (`string`, default: `null`). +URL to your backend or to [Companion](/docs/companion) (`string`, default: +`null`). -#### `companionHeaders` +#### `headers` -Custom headers that should be sent along to [Companion](/docs/companion) on -every request (`Object`, default: `{}`). +Custom headers that should be sent along to the [`endpoint`](#endpoint) on every +request (`Object`, default: `{}`). -#### `companionCookiesRule` +#### `cookiesRule` 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). +This tells the plugin whether to send cookies to the [`endpoint`](#endpoint). #### `retryDelays` @@ -386,9 +387,9 @@ The default implementation calls out to Companion’s S3 signing endpoints. Pass an array of field names to limit the metadata fields that will be added to upload as query parameters. -- Set this to `['name']` to only send the `name` field. -- Set this to `null` (the default) to send _all_ metadata fields. -- Set this to an empty array `[]` to not send any fields. +- Set it to `false` to not send any fields (or an empty array). +- Set it to `['name']` to only send the `name` field. +- Set it to `true` (the default) to send _all_ metadata fields.