Skip to content

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

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
musthafa1996 opened this issue Oct 20, 2022 · 6 comments
Closed

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

musthafa1996 opened this issue Oct 20, 2022 · 6 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@musthafa1996
Copy link

musthafa1996 commented Oct 20, 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

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

@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 20, 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.

@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Oct 20, 2022
@mtrezza mtrezza changed the title File upload error 'The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined' File upload fails using REST API --data-raw Oct 20, 2022
@musthafa1996
Copy link
Author

Related to parse-community/Parse-SDK-JS#1579

@musthafa1996
Copy link
Author

Fixed with parse-community/Parse-SDK-JS#1578

@mtrezza mtrezza reopened this Nov 4, 2022
@mtrezza
Copy link
Member

mtrezza commented Nov 4, 2022

Before we close this issue, just to confirm, the issue only existed when using the former alpha version of the Parse JS SDK with Parse Server. Since Parse Server never used that alpha version of the SDK (not even in a pre-release version), it was never an issue that occurred in any version of Parse Server. Is that correct?

@musthafa1996
Copy link
Author

Yes, that's right.

@mtrezza
Copy link
Member

mtrezza commented Nov 10, 2022

Thanks for confirming.

@mtrezza mtrezza closed this as completed Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

2 participants