private static void transferData(InputStream is, OutputStream os, long sizeLimitBytes) {
        try (is) {
            byte[] buff = new byte[COPY_BUFF_SIZE_BYTES];
            long bytesTransferred = 0;
            int bytesRead;
            while ((bytesRead = is.read(buff, 0, COPY_BUFF_SIZE_BYTES)) >= 0) {
                os.write(buff, 0, bytesRead);
                bytesTransferred += bytesRead;
                if (bytesTransferred > sizeLimitBytes) {
                    RestArgumentVerifier.checkSizeMax(bytesTransferred, sizeLimitBytes, "Provided file is larger than the limit of " + sizeLimitBytes + "b");
                }
            }
            // If blob is very small, may be an error or DOS/spam
            RestArgumentVerifier.checkArgument(bytesTransferred > 10, "Provided file too small");
        } catch (IOException ioe) {
            IOUtils.closeQuietly(os);
            throw new UncheckedIOException(ioe);
        }
    }
@author Marc Savy {@literal <marc@blackparrotlabs.io>}
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/MultipartHelper.java