Skip to content

Commit

Permalink
@uppy/companion: remove sanitizing of metadata (#5198)
Browse files Browse the repository at this point in the history
Now that we are no longer using form-data which had a bug
and crashed when sending non-string meta.
  • Loading branch information
mifi authored and aduh95 committed May 30, 2024
1 parent e11493f commit 1808d36
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions packages/@uppy/companion/src/server/Uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ function exceedsMaxFileSize(maxFileSize, size) {
return maxFileSize && size && size > maxFileSize
}

// TODO remove once we migrate away from form-data
function sanitizeMetadata(inputMetadata) {
if (inputMetadata == null) return {}

const outputMetadata = {}
Object.keys(inputMetadata).forEach((key) => {
outputMetadata[key] = String(inputMetadata[key])
})
return outputMetadata
}

class ValidationError extends Error {
name = 'ValidationError'
}
Expand Down Expand Up @@ -178,7 +167,7 @@ class Uploader {
this.options = options
this.token = randomUUID()
this.fileName = `${Uploader.FILE_NAME_PREFIX}-${this.token}`
this.options.metadata = sanitizeMetadata(this.options.metadata)
this.options.metadata = this.options.metadata || {}
this.options.fieldname = this.options.fieldname || DEFAULT_FIELD_NAME
this.size = options.size
this.uploadFileName = this.options.metadata.name
Expand Down

0 comments on commit 1808d36

Please sign in to comment.