Skip to content
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

Uploading file fails #794

Closed
GochoMugo opened this issue May 14, 2020 · 2 comments · Fixed by #797
Closed

Uploading file fails #794

GochoMugo opened this issue May 14, 2020 · 2 comments · Fixed by #797

Comments

@GochoMugo
Copy link

Description

With the code below:

const content = fs.createReadStream(filepath);
await this.gitlab.Projects.upload(projectId, content, {
    metadata: {
         filename,
    },
});

the following error is thrown:

TypeError: source.on is not a function
    at Function.DelayedStream.create (<redacted>/node_modules/delayed-stream/lib/delayed_stream.js:33:10)
    at FormData.CombinedStream.append (<redacted>/node_modules/combined-stream/lib/combined_stream.js:45:37)
    at FormData.append (<redacted>/node_modules/form-data/lib/form_data.js:73:3)
    at <redacted>/node_modules/@gitbeaker/core/dist/index.js:1:4008
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (<redacted>/node_modules/@gitbeaker/core/dist/index.js:1:3919)
    at <redacted>/node_modules/@gitbeaker/core/dist/index.js:1:3123
    at Object.next (<redacted>/node_modules/@gitbeaker/core/dist/index.js:1:3228)
    at <redacted>/node_modules/@gitbeaker/core/dist/index.js:1:2165
    at new Promise (<anonymous>)

Possible fixes

Usage of dependency form-data is wrong when handling
files i.e. on line packages/gitbeaker-core/src/infrastructure/Utils.ts#L29.

A possible fix:

else if ('content' in (v as any) && 'metadata' in (v as any)) form.append(k, (v as any).content, (v as any).metadata);
@jdalrymple jdalrymple added the bug label May 15, 2020
@jdalrymple
Copy link
Owner

I messed up the usage, ill fix this up before the end of the week!

@jdalrymple
Copy link
Owner

🚀 Issue was released in 19.6.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants