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

YOUR SOLUTION IS NOT CORRECT! #1475

Closed
playground opened this issue May 20, 2024 · 2 comments
Closed

YOUR SOLUTION IS NOT CORRECT! #1475

playground opened this issue May 20, 2024 · 2 comments

Comments

@playground
Copy link

playground commented May 20, 2024

Following instructions https://web3.storage/docs/ to store a file

import * as Client from '@web3-storage/w3up-client'
import { filesFromPaths } from 'files-from-path'

const client = await Client.create()
const files = await filesFromPaths(['/Users/test/w3up/example.json'])
client.uploadFile(files).then((did) => console.log(did))

but getting these errors

learnyouw3up verify ex3.mjs
Verifying /Users/test/w3up/ex3.mjs...

file:///Users/test/.nvm/versions/node/v18.17.1/lib/node_modules/learnyouw3up/node_modules/execa/lib/error.js:60
                error = new Error(message);
                        ^

Error: Command failed with exit code 1: /Users/test/.nvm/versions/node/v18.17.1/bin/node /Users/test/w3up/ex3.mjs
file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:51
        await this.#file.stream().pipeTo(new WritableStream({
                         ^

TypeError: this[#file].stream is not a function
    at UnixFSFileBuilder.finalize (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:51:26)
    at file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:33:27
    at Module.createFileEncoderStream (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:35:7)
    at uploadFile (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/index.js:38:49)
    at Client.uploadFile (file:///Users/test/w3up/node_modules/@web3-storage/w3up-client/dist/src/client.js:92:16)

Node.js v18.17.1
    at makeError (file:///Users/test/.nvm/versions/node/v18.17.1/lib/node_modules/learnyouw3up/node_modules/execa/lib/error.js:60:11)
    at handlePromise (file:///Users/test/.nvm/versions/node/v18.17.1/lib/node_modules/learnyouw3up/node_modules/execa/index.js:124:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///Users/test/.nvm/versions/node/v18.17.1/lib/node_modules/learnyouw3up/problems/2-cat-gifs/index.js:21:29 {
  shortMessage: 'Command failed with exit code 1: /Users/test/.nvm/versions/node/v18.17.1/bin/node /Users/test/w3up/ex3.mjs',
  command: '/Users/test/.nvm/versions/node/v18.17.1/bin/node /Users/test/w3up/ex3.mjs',
  escapedCommand: '"/Users/test/.nvm/versions/node/v18.17.1/bin/node" "/Users/test/w3up/ex3.mjs"',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: 'file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:51\n' +
    '        await this.#file.stream().pipeTo(new WritableStream({\n' +
    '                         ^\n' +
    '\n' +
    'TypeError: this[#file].stream is not a function\n' +
    '    at UnixFSFileBuilder.finalize (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:51:26)\n' +
    '    at file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:33:27\n' +
    '    at Module.createFileEncoderStream (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:35:7)\n' +
    '    at uploadFile (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/index.js:38:49)\n' +
    '    at Client.uploadFile (file:///Users/test/w3up/node_modules/@web3-storage/w3up-client/dist/src/client.js:92:16)\n' +
    '\n' +
    'Node.js v18.17.1',
  cwd: '/Users/test/w3up',
  all: 'file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:51\n' +
    '        await this.#file.stream().pipeTo(new WritableStream({\n' +
    '                         ^\n' +
    '\n' +
    'TypeError: this[#file].stream is not a function\n' +
    '    at UnixFSFileBuilder.finalize (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:51:26)\n' +
    '    at file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:33:27\n' +
    '    at Module.createFileEncoderStream (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/unixfs.js:35:7)\n' +
    '    at uploadFile (file:///Users/test/w3up/node_modules/@web3-storage/upload-client/dist/src/index.js:38:49)\n' +
    '    at Client.uploadFile (file:///Users/test/w3up/node_modules/@web3-storage/w3up-client/dist/src/client.js:92:16)\n' +
    '\n' +
    'Node.js v18.17.1',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Node.js v18.17.1
@playground
Copy link
Author

playground commented May 20, 2024


#########################################
###   YOUR SOLUTION IS NOT CORRECT!   ###
#########################################


Invalid CID: ""

@playground playground changed the title TypeError: this[#file].stream is not a function YOUR SOLUTION IS NOT CORRECT! May 20, 2024
@alanshaw
Copy link
Member

alanshaw commented Jun 4, 2024

uploadFile expects a single file, not an array. Try using uploadDirectory or files[0] in you call.

@alanshaw alanshaw closed this as completed Jun 4, 2024
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

No branches or pull requests

2 participants