本文整理汇总了Java中io.vertx.core.http.HttpServerFileUpload.handler方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerFileUpload.handler方法的具体用法?Java HttpServerFileUpload.handler怎么用?Java HttpServerFileUpload.handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.http.HttpServerFileUpload
的用法示例。
在下文中一共展示了HttpServerFileUpload.handler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import io.vertx.core.http.HttpServerFileUpload; //导入方法依赖的package包/类
/**
* Uploads the file contents to S3.
*
* @param aBucket An S3 bucket
* @param aKey An S3 key
* @param aUpload An HttpServerFileUpload
* @param aHandler An upload response handler
*/
public void put(final String aBucket, final String aKey, final HttpServerFileUpload aUpload,
final Handler<HttpClientResponse> aHandler) {
final S3ClientRequest request = createPutRequest(aBucket, aKey, aHandler);
final Buffer buffer = Buffer.buffer();
aUpload.endHandler(event -> {
request.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(buffer.length()));
request.end(buffer);
});
aUpload.handler(data -> {
buffer.appendBuffer(data);
});
}
示例2: checkSize
import io.vertx.core.http.HttpServerFileUpload; //导入方法依赖的package包/类
/**
* Checks whether we exceed the max allowed file size.
*
* @param newSize the expected size once the current chunk is consumed
* @param maxSize the max allowed size.
* @param upload the upload
*/
private void checkSize(long newSize, long maxSize, HttpServerFileUpload upload) {
if (maxSize >= 0 && newSize > maxSize) {
upload.handler(null);
report(new IllegalStateException("Size exceed allowed maximum capacity"));
}
}