Переглянути джерело

@uppy/url: enable passing optional meta data to `addFile` (#3788)

This commit aligns `@uppy/url` with `@uppy/core`.

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
Brad Edelman 2 роки тому
батько
коміт
a8726ba06b

+ 2 - 1
packages/@uppy/url/src/Url.jsx

@@ -105,7 +105,7 @@ export default class Url extends UIPlugin {
       })
   }
 
-  async addFile (protocollessUrl) {
+  async addFile (protocollessUrl, optionalMeta = undefined) {
     const url = this.addProtocolToURL(protocollessUrl)
     if (!this.checkIfCorrectURL(url)) {
       this.uppy.log(`[URL] Incorrect URL entered: ${url}`)
@@ -117,6 +117,7 @@ export default class Url extends UIPlugin {
       const meta = await this.getMeta(url)
 
       const tagFile = {
+        meta: optionalMeta,
         source: this.id,
         name: this.getFileNameFromUrl(url),
         type: meta.type,

+ 2 - 2
packages/@uppy/url/types/index.d.ts

@@ -1,4 +1,4 @@
-import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
+import type { PluginOptions, UIPlugin, PluginTarget, IndexedObject } from '@uppy/core'
 import type { RequestClientOptions } from '@uppy/companion-client'
 import UrlLocale from './generatedLocale'
 
@@ -9,7 +9,7 @@ export interface UrlOptions extends PluginOptions, RequestClientOptions {
 }
 
 declare class Url extends UIPlugin<UrlOptions> {
-  public addFile(url: string): undefined | string | never
+  public addFile(url: string, meta?: IndexedObject<any>): undefined | string | never
 }
 
 export default Url