I would like to post CSV formatted data to an external URL. The URL requires a multipart form containing a string and a file. It seems to me that this requires saving a file to disk before I can call the URL. Is it possible to use this URL (It is the US Census Bureau's geocoding service) without saving a file to disk? For example, can I use a ByteArrayInputStream that only lives temporarily in memory? Below is my initial code that involves saving a file to disk.
        String benchmark = "9";
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPost uploadFile = new HttpPost("https://geocoding.geo.census.gov/geocoder/locations/addressbatch");
        MultipartEntityBuilder builder2 = MultipartEntityBuilder.create();
        builder2.addTextBody("benchmark", benchmark, ContentType.TEXT_PLAIN);
        File f = new File("UscbGeocodingInput.csv");
        FileInputStream is = new FileInputStream(f);
        builder2.addBinaryBody(
                "addressFile",
                is,
                ContentType.APPLICATION_OCTET_STREAM,
                f.getName());
        HttpEntity multipart = builder2.build();
        uploadFile.setEntity(multipart);
        CloseableHttpResponse response = httpClient.execute(uploadFile);
I don't want to save a file to disk because it only needs to exist temporarily until we call the external URL. I tried to use a byte array input stream in instead of a FileInputStream, but the request then fails this way with a 400 error.