<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NotImplemented</Code><Message>A header you provided implies functionality that is not implemented</Message><Header>Transfer-Encoding</Header><RequestId>4B2C926CF0A17F5C</RequestId><HostId>z+6pGNjvut3a6wUaZ5ILw3+0GqiLmj4+5KnfdzqR2+FzzJ6SBgKKPHwEthtORDEx1QTt2N4lg7U=</HostId></Error>Here's (part of) the code I'm using:
HttpServerRequest req = rc.request();
req.setExpectMultipart(true);
Handler<HttpClientResponse> h = new Handler<HttpClientResponse>() {
@Override
public void handle(HttpClientResponse hcr) {
System.out.println("S3 statuscode: "+hcr.statusCode());
System.out.println("S3 statuscode: "+hcr.statusMessage());
hcr.bodyHandler(new Handler<Buffer>() {
@Override
public void handle(Buffer buffer) {
System.out.println("Response (" + buffer.length() + "): ");
System.out.println(buffer.getString(0, buffer.length()));
}
});
}
};
S3Client s3 = new S3Client("key","key");
S3ClientRequest putRequest = s3.createPutRequest("bazana-demo-datasets", "test.csv", h);
putRequest.setChunked(true);
System.out.println("created the request");
req.uploadHandler(upload -> {
upload.handler(chunk -> {
System.out.println("Received a chunk of the upload of length " + chunk.length());
putRequest.write(chunk);
});
});
req.endHandler(request -> {
putRequest.end();
});
Thanks,
Patrick
router.post("/os").handler(ctx -> { ctx.response().setChunked(true);
String accessKey = "<Your Key Goes Here>"; String secretKey = "<Your Secret Goes Here>"; String bucket = "<Your Bucket Goes Here>"; String endpoint = "<Your Endpoint Goes Here>";
HttpServerRequest req = ctx.request(); String contentLength = req.getHeader("Content-Length");
// Pause reading the body of the request until the callbacks are hooked up in the Pump req.pause();
S3Client s3c = new S3Client(vertx, accessKey, secretKey, null, endpoint);
S3ClientRequest s3cr = s3c.createPutRequest(bucket, "filename", resp2 -> { ctx.response().end("All Done.\n"); }); s3cr.putHeader("Content-Length", contentLength); Pump pump = Pump.pump(req, s3cr); // End the connection of our request to the data store after our client is finished sending. req.endHandler(v -> s3cr.end()); // Turn the spigot, let it flow, let it flow, don't hold it back anymore..... pump.start(); req.resume();});