flowjs / ng-flow

Flow.js html5 file upload extension on angular.js framework
http://flowjs.github.io/ng-flow/
MIT License
1.38k stars 303 forks source link

Can't get an inputStream #352

Closed hua2an closed 6 years ago

hua2an commented 6 years ago

Why did I get an inputStream with nothing, but it contains information like headers, Int r = is. Read (bytes) r is -1 `
RandomAccessFile raf = new RandomAccessFile(new File("D:\"+flowFilename), "rw");

    //Seek to position
    raf.seek((flowChunkNumber - 1) * flowChunkSize);

    //Save to file
    InputStream is = request.getInputStream();
    long readed = 0;
    long content_length = request.getContentLength();
    byte[] bytes = new byte[1024 * 100];
    while(readed < content_length) {
        int r = is.read(bytes);
        if (r < 0)  {
            break;
        }
        raf.write(bytes, 0, r);
        readed += r;
    }
    raf.close();

`

AidasK commented 6 years ago

It is probably a test request with GET method. Please view implementation samples at https://github.com/flowjs/flow.js/tree/master/samples