Skip to content

Issue uploading files #1579

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

Closed
4 tasks done
musthafa1996 opened this issue Oct 21, 2022 · 7 comments · Fixed by #1578
Closed
4 tasks done

Issue uploading files #1579

musthafa1996 opened this issue Oct 21, 2022 · 7 comments · Fixed by #1578
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@musthafa1996
Copy link
Contributor

musthafa1996 commented Oct 21, 2022

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)"}

@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 21, 2022

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@musthafa1996
Copy link
Contributor Author

Here's a PR with failing test cases: #1578

@mtrezza mtrezza added type:bug Impaired feature or lacking behavior that is likely assumed block:beta Needs to be resolved before next release on beta branch; remove label afterwards labels Nov 1, 2022
@mtrezza
Copy link
Member

mtrezza commented Nov 1, 2022

Note: This issue is currently blocking the beta release #1589

@mtrezza mtrezza removed the block:beta Needs to be resolved before next release on beta branch; remove label afterwards label Nov 3, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.0-alpha.8

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Nov 3, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 3, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1-alpha.1

@mtrezza mtrezza added the bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) label Nov 4, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants