Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable passing optional meta data to Uppy URL plugin's addFile API #3788

Merged
merged 8 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/@uppy/url/src/Url.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class Url extends UIPlugin {
})
}

async addFile (protocollessUrl) {
async addFile (protocollessUrl, optionalMeta = undefined) {
bradedelman marked this conversation as resolved.
Show resolved Hide resolved
Murderlon marked this conversation as resolved.
Show resolved Hide resolved
const url = this.addProtocolToURL(protocollessUrl)
if (!this.checkIfCorrectURL(url)) {
this.uppy.log(`[URL] Incorrect URL entered: ${url}`)
Expand All @@ -116,6 +116,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,
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/url/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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