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

Can't upload files in electron app console (webui works fine) #23

Closed
daviddias opened this issue Aug 4, 2015 · 10 comments
Closed

Can't upload files in electron app console (webui works fine) #23

daviddias opened this issue Aug 4, 2015 · 10 comments
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@daviddias
Copy link
Member

Throws this error:

[41549:0804/182709:INFO:CONSOLE(895)] "adding file: ", source: http://127.0.0.1:5001/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6/bundle.js (895)
[41549:0804/182709:INFO:CONSOLE(21740)] "Uncaught TypeError: fs.createReadStream is not a function", source: http://127.0.0.1:5001/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6/bundle.js (21740)
@jbenet
Copy link
Member

jbenet commented Aug 5, 2015

😢

@daviddias daviddias added the kind/bug A bug in existing code (including security flaws) label Aug 12, 2015
@daviddias
Copy link
Member Author

The only fs.createReadStream is on this function of the Bundle:

  function getFileStream (files, boundary) {
    if (!files) return null

    var mp = new Multipart(boundary)
    if (!Array.isArray(files)) files = [files]

    for (var i in files) {
      var file = files[i]

      if (typeof file === 'string') {
        // TODO: get actual content type
        mp.addPart({
          body: fs.createReadStream(file),
          headers: {
            'Content-Type': 'application/octet-stream',
            'Content-Disposition': 'file; name="file"; filename="' + file + '"'
          }
        })

      } else if (Buffer.isBuffer(file)) {
        mp.addPart({
          body: file,
          headers: {
            'Content-Type': 'application/octet-stream',
            'Content-Disposition': 'file; name="file"; filename=""'
          }
        })
      }
    }

    return mp
  }

@daviddias
Copy link
Member Author

In console mode, this file is empty:

https://github.com/ipfs/webui/blob/master/js/pages/files.jsx#L78
[14147:0812/231317:INFO:CONSOLE(895)] "adding file: ", source: http://127.0.0.1:5001/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6/bundle.js (895)

And that is why it evals it to a string and breaks.

@jbenet
Copy link
Member

jbenet commented Aug 13, 2015

I believe this is fixed for you now

@daviddias
Copy link
Member Author

Needs ipfs/ipfs-webui#75 to be merged and released

@daviddias daviddias added this to the v0.1.0 milestone Aug 18, 2015
@jbenet
Copy link
Member

jbenet commented Aug 19, 2015

ipfs/ipfs-webui#75 merged. release is trickier-- need to PR against go-ipfs.

(we should think about how to do upgrades without requiring compilation. easy options for now:

  • require config change (ew)
  • give user a big warning page, (and user can chose to "install it" to allow it henceforth.) (very tricky UX for security)
  • sign the root, check for our sig. (this is cool)

@dignifiedquire
Copy link
Member

@diasdavid can we close this?

@daviddias daviddias modified the milestones: v0.1.0, 1.0.0 Oct 12, 2015
@daviddias
Copy link
Member Author

Getting this error with the new electron versions

[1] (node) warning: possible EventEmitter memory leak detected. 11 did-finish-load listeners added. Use emitter.setMaxListeners() to increase limit.
[1] Trace
[1]     at EventEmitter.addListener (events.js:239:17)
[1]     at EventEmitter.once (events.js:265:8)
[1]     at EventEmitter.webContents.executeJavaScript (/Users/david/Documents/code/ipfs/station/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/atom.asar/browser/api/lib/web-contents.js:69:28)
[1]     at /Users/david/Documents/code/ipfs/station/node_modules/electron-safe-ipc/host.js:19:24
[1]     at Array.forEach (native)
[1]     at EventEmitter.ipc.send (/Users/david/Documents/code/ipfs/station/node_modules/electron-safe-ipc/host.js:14:33)
[1]     at /Users/david/Documents/code/ipfs/station/build/init.js:73:9
[1]     at IncomingMessage.<anonymous> (/Users/david/Documents/code/ipfs/station/node_modules/ipfs-api/src/request-api.js:89:14)
[1]     at emitNone (events.js:72:20)
[1]     at IncomingMessage.emit (events.js:166:7)

Ideas why?

@dignifiedquire
Copy link
Member

Ideas why?

Not really, I think somewhere where are not cleaning up properly, but I wasn't able to track down where exactly.

@dignifiedquire
Copy link
Member

Closing as this should work now, please reopen with details if still an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

No branches or pull requests

3 participants