-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Error: upload.arrayBuffer is not a function #8497
Comments
Thanks for opening this issue!
|
Hi @VKlapan, Parse GraphQL server follow the multi part graphql upload spec. You can't simply call a mutation into the Dashboard GraphQL console. Parse GraphQL server does not support base 64 file upload ( it's also a really bad practice since it do not leverage streaming, multi part http systems) You can see some client side examples: https://github.com/jaydenseric/graphql-multipart-request-spec Or you can give a try to https://altairgraphql.dev/ that support multi part file upload. |
I'm closing this as it does not seem to be a Parse Server issue.
|
Thanks. |
So... For example, I have a question: But I have error: {"error":"Unexpected token - in JSON at position 0"} |
a few more details: I have this error on my parse server 6.0.0 : Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client Does anybody know how to fix it ? |
Hi @VKlapan we can't help here until you provide more details to reproduce the error, can you share a failing test or a reproduction repository. I use the alpha release of Parse Server in production with file upload, my team has a lot of upload tests we don't have any issue. |
Hi @Moumouls on web app
Payload on DevTools/Neywork: response: server log:
|
Hi @VKlapan , you have may be forgot to use a compatible upload client ? Like: https://www.apollographql.com/docs/react/data/file-uploads/ |
@Moumouls "dependencies": {
|
Did you setup correctly the Apollo upload link ? |
I'm not sure(((( UPD:
|
import { createUploadLink } from 'apollo-upload-client'
import {
InMemoryCache,
ApolloClient,
} from '@apollo/client'
const options = const options = {
uri: graphQLUrl,
}
const client = new ApolloClient({
cache: new InMemoryCache(),
link: createUploadLink(options),
}) You client should be initialized like this @VKlapan |
I can be wrong, but I think that I have the same.
@Moumouls help me to find my bugs ((( |
UPD I use Altair GraphQL Client, which has embedded File upload mechanism and I receive the same Error:
Can anybody explain to me - why? The base features don't work ! What is very important - I use Parse Server 6.0.0 |
Okay @VKlapan it's weird can you provide a reproduction repo with the failing behavior, for example just a simple react app with the apollo upload client configured and a guide to reproduce the error. I think it will be the only solution to understand the issue since parse server test suite is working correctly on this feature and also in my company we don't have any issue with this one ( we run on latest parse server version + some additional features from my fork) |
Reopened as the issue seems to require investigation |
Ok @Moumouls I'll create a repo. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I'm currently looking into the same issue on Parse Server 5.3.3. On development, I was able to fix both the On staging/production, the server is not started via a custom script but from the command line. Above error can be resolved by patching ParseServer.js and mounting 'this.app' after GraphQL.
I'm still testing if this has any side effects but if not, I'll create a PR. |
It's related to the deepcopy of mutation args, converting the file object to a standard object. I don't know why it happens now ( maybe a package update side effect) |
🎉 This change has been released in version 7.0.0-alpha.14 |
🎉 This change has been released in version 7.0.0-beta.1 |
🎉 This change has been released in version 7.0.0 |
New Issue Checklist
Issue Description
When I try to upload a file (via Parse Dashboard GraphQL API Console) I receive an error:
"upload.arrayBuffer is not a function".
Do not understand - what is wrong?
Steps to reproduce
Try to check file uploading via Parse Dashboard GraphQL API Console.
Query:
mutation createFile($file: Upload!) { createFile(input: {upload:$file}) { fileInfo { name url } } }
Variables - base64 string:
{ "file":"V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE=" }
Actual Outcome
Response:
{ "errors": [ { "message": "upload.arrayBuffer is not a function", "locations": [ { "line": 2, "column": 3 } ], "path": [ "createFile" ] } ], "data": { "createFile": null } }
Expected Outcome
Environment
Server
6.0.0
Linux Mint 20.2 Cinnamon and docker
local
Database
MongoDB
mongo:4
local
Client
JavaScript
"@types/parse": "^2.18.13"
Logs
server config:
`
Successfully compiled 1 file with Babel (297ms).
SERVER CONFIG
Configuration loaded from /parse-server/config/server.js
warn: DeprecationWarning: The Parse Server option 'allowClientClassCreation' default will change to 'false' in a future version.
warn: DeprecationWarning: The Parse Server option 'allowExpiredAuthDataToken' default will change to 'false' in a future version.
RUN Parse Server Cloud
allowClientClassCreation: true
allowCustomObjectId: false
allowExpiredAuthDataToken: true
allowHeaders: ["X-Apollo-Tracing"]
appId: parse-template
appName: Parse Template
cacheMaxSize: 10000
cacheTTL: 5000
cloud: /parse-server/cloud-dist
collectionPrefix:
customPages: {"invalidLink":"http://localhost/invalid-link","invalidVerificationLink":"http://localhost/invalid-verification-link","passwordResetSuccess":"http://localhost/password-reset-success","choosePassword":"http://localhost/choose-password"}
databaseURI: mongodb://db/parse
defaultLimit: 100
directAccess: true
emailAdapter: {"options":{"service":"SMTP","fromAddress":"dev@.com","user":"dev@","password":"","host":"mail..com","port":587,"isSSL":false,"templates":{"resetPassword":{"path":"/parse-server/templates/reset-password","subject":"Password reset"},"verifyEmail":{"path":"/parse-server/templates/verify-email","subject":"Email verification"}}}}
emailVerifyTokenReuseIfValid: false
emailVerifyTokenValidityDuration: 7200
enableAnonymousUsers: true
enableExpressErrorHandler: false
enforcePrivateUsers: true
expireInactiveSessions: true
filesAdapter: {"_encryptionKey":null,"_filesDir":"/parse-server/files"}
fileUpload: {"enableForPublic":true,"enableForAnonymousUser":true,"enableForAuthenticatedUser":true}
graphQLPath: /graphql
graphQLSchema: /parse-server/schema.graphql
host: 0.0.0.0
idempotencyOptions: {"ttl":300,"paths":[]}
liveQuery: {"classNames":[]}
logLevel: warn
logLevels: {"triggerAfter":"info","triggerBeforeError":"error","triggerBeforeSuccess":"info"}
logsFolder: ./logs
maintenanceKeyIps: ["127.0.0.1","::1"]
masterKey: REDACTED
masterKeyIps: ["172.30.0.0/16"]
maxUploadSize: 4000mb
mountGraphQL: true
mountPath: /
mountPlayground: false
objectIdSize: 10
pages: {"enableRouter":false,"enableLocalization":false,"localizationFallbackLocale":"en","placeholders":{},"forceRedirect":false,"pagesPath":"./public","pagesEndpoint":"apps","customUrls":{},"customRoutes":[]}
passwordPolicy: {"doNotAllowUsername":true,"resetTokenValidityDuration":10800}
playgroundPath: /playground
port: 1337
preserveFileName: false
preventLoginWithUnverifiedEmail: false
protectedFields: {"_User":{"":["email"],"role:admin":[]}}
publicServerURL: http://localhost:1337
rateLimit: []
requestKeywordDenylist: [{"key":"_bsontype","value":"Code"},{"key":"constructor"},{"key":"proto"}]
restAPIKey: asd78sd897df09as87dfh09asd
revokeSessionOnPasswordReset: true
scheduledPush: false
security: {"enableCheck":false,"enableCheckLog":false}
sessionLength: 31536000
startLiveQueryServer: true
trustProxy: []
verbose: false
verifyUserEmails: true
jsonLogs: false
level: undefined
serverURL: http://localhost:1337/
state: initialized
`
The text was updated successfully, but these errors were encountered: