Skip to content

Issue uploading files #1579

Closed
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

Using File API of Parse SDK:

const file = new Parse.File('parse-server-logo', {
  base64: 'data:image/jpeg;base64,ParseA==',
});
await file.save();

Using 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

For File API of Parse SDK:

The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined

For File upload Rest API:

{
    "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 with Parse SDK version ^3.5.0-alpha.6. Please note that the same version of Parse SDK must be used in Parse Server. Parse Server uses the latest released version of Parse SDK (3.4.2) by default. You will need to override the SDK version for Parse server. To do so, you can add the following in package.json:

"overrides": {
  "parse-server": {
    "parse": "^3.5.0-alpha.6"
  }
}

Also note that npm package overriding is only supported from npm version >=8.3.0.

Server

  • Parse Server version: 5.2.8, 5.3.0-alpha.30
  • 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

    bounty:$20Bounty applies for fixing this issue (Parse Bounty Program)state:releasedReleased as stable versionstate:released-alphaReleased as alpha versionstate:released-betaReleased as beta versiontype: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