Skip to content

File upload fails using REST API --data-raw #8253

Closed
@musthafa1996

Description

@musthafa1996

New Issue Checklist

Issue Description

Parse server throws the following error while uploading files:
The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined

Steps to reproduce

The issue could be reproduced using the following curl request for File upload Rest API:

curl --location --request POST 'http://198.199.84.19:1337/parse/files/test.txt' \
--header 'X-Parse-Application-Id: <APP_ID>' \
--header 'X-Parse-REST-API-Key: <REST_API_KEY>' \
--header 'X-Parse-Master-Key: <MASTER_KEY>' \
--header 'Content-Type: application/text' \
--data-raw 'Hello world' 

Actual Outcome

The above request must respond with:

{
    "code": 130,
    "error": "The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined"
}

Expected Outcome

Successfully upload the file and respond with the URL to the file. A sample success response would be:

{
    "url": "http://localhost:1337/parse/files/APP_ID/0fef055962401a0c5d23d9c10b737a07_test.txt",
    "name": "0fef055962401a0c5d23d9c10b737a07_test.txt"
}

Environment

This issue occurs on the latest released version of parse-server 5.2.8, as well as in the latest alpha version 5.3.0-alpha.30.

Server

  • Parse Server version: 5.2.8
  • Operating system: macOS Monterey, Ubuntu 22.04.1 LTS
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local. Digital Ocean

Database

  • System (MongoDB or Postgres): Postgres
  • Database version: PostgreSQL 14.1
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local, 'Digital Ocean'

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): Javascript
  • SDK version: ^3.5.0-alpha.6

Logs

error: Error creating a file: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined {"code":"ERR_INVALID_ARG_TYPE","stack":"TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined\n at new NodeError (node:internal/errors:393:5)\n at Function.from (node:buffer:328:9)\n at createHandler (/api/node_modules/parse-server/src/Routers/FilesRouter.js:167:35)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)"} error: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined {"code":130,"stack":"TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined\n at new NodeError (node:internal/errors:393:5)\n at Function.from (node:buffer:328:9)\n at createHandler (/api/node_modules/parse-server/src/Routers/FilesRouter.js:167:35)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions