Skip to content

Programmatically uploading (geo)JSON files throws mimetype error #2203

@stefgootzen

Description

@stefgootzen

Bug Report

Calling this:

const filePath = '[...]/filename.geojson';

await payload.create({
    collection: 'geofiles',
    filePath: tmpFilePath,
    data: {}
  });

results in the following error:

TypeError: Cannot read properties of undefined (reading 'mime')
    at getFileByPath ([...]/node_modules/payload/src/uploads/getFileByPath.ts:16:34)
    at async createLocal ([...]/node_modules/payload/src/collections/operations/local/create.ts:65:21)

I'm using Payload 1.6.6.

Possible cause

I believe the problem lies in the the following code const mimetype = fromFile(filePath); (link) which ultimately in the file-type package does this new FileTypeParser().parse(tokenizer);.

FileTypeParser.parse() (link) does not support (geo)JSON.

The file-type states This package is for detecting binary-based file formats, not text-based formats like .txt, .csv, .svg, etc., does this mean that the payload upload system also only supports binary-based file formats?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagePossible bug which hasn't been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions