Amazon S3 Connector Import Warning

5
When trying to import excel files I get the following warnings: com.amazonaws.services.s3.internal.S3AbortableInputStream close Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection. This is likely an error and may result in sub-optimal behavior. Request only the bytes you need via a ranged GET or drain the input stream after use.   I’m not sure why this warning is being thrown, but suspect versioning of either the excel importer or the Amazon S3 Connector.
asked
1 answers
0

In this case I think this should be reported as an error in ExcelImporter.

But this warning happens in a java action I wrote as well. It reads a file but not completely. I solved it by reading all bytes, see the code below.

Instead of simply closing the InputStream call the function drainAndClose.

 

    public void drainAndClose(InputStream is) {
        boolean done = false;
        
        while (!done) {
            try {
                is.skip(is.available());  // Skip as many bytes as available
                int nextByte = is.read(); // Try to read one byte further
                if (nextByte < 0) {       // End of file reached
                    done = true;
                }
            } catch (IOException e) {
                done = true;
            }
        }
    
        try {
            is.close();
        } catch (IOException e) {
        }
    }

answered