本文整理汇总了Java中io.vertx.core.http.HttpServerFileUpload类的典型用法代码示例。如果您正苦于以下问题:Java HttpServerFileUpload类的具体用法?Java HttpServerFileUpload怎么用?Java HttpServerFileUpload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpServerFileUpload类属于io.vertx.core.http包,在下文中一共展示了HttpServerFileUpload类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: tempFile
import io.vertx.core.http.HttpServerFileUpload; //导入依赖的package包/类
/**
* Creates a temporary file.
*
* @return a new Temp File from getDiskFilename(), default prefix, postfix and baseDirectory
*/
static synchronized File tempFile(HttpServerFileUpload upload) {
String newpostfix;
String diskFilename = new File(upload.filename()).getName();
newpostfix = '_' + diskFilename;
File tmpFile;
try {
if (baseDirectory == null) {
// create a temporary file
tmpFile = File.createTempFile(prefix, newpostfix);
} else {
tmpFile = File.createTempFile(prefix, newpostfix, new File(
baseDirectory));
}
if (deleteOnExitTemporaryFile) {
tmpFile.deleteOnExit();
}
return tmpFile;
} catch (IOException e) {
// Really bad, can't create the tmp file.
throw new IllegalStateException(e);
}
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:29,代码来源:DiskFileUpload.java
示例2: 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);
});
}
开发者ID:ksclarke,项目名称:vertx-pairtree,代码行数:23,代码来源:S3Client.java
示例3: MixedFileUpload
import io.vertx.core.http.HttpServerFileUpload; //导入依赖的package包/类
/**
* Creates an instance of {@link org.wisdom.framework.vertx.file.VertxFileUpload}.
*
* @param vertx the Vert.X instance
* @param upload the upload object
* @param limitSize the threshold. If the amount of uploaded data is below this limit,
* {@link org.wisdom.framework.vertx.file.MemoryFileUpload} is used to backend the uploaded file.
* Otherwise, it uses a {@link org.wisdom.framework.vertx.file.DiskFileUpload}.
*/
public MixedFileUpload(final Vertx vertx,
final HttpServerFileUpload upload,
final long limitSize,
final long maxSize,
final Handler<Result> errorHandler) {
super(upload, errorHandler);
delegate = new MemoryFileUpload(upload, errorHandler);
upload.exceptionHandler(event -> LoggerFactory.getLogger(MixedFileUpload.class)
.error("Cannot read the uploaded item {} ({})", upload.name(), upload.filename(), event))
.endHandler(event -> delegate.close())
.handler(
event -> {
if (event != null) {
// We are still in memory.
if (delegate instanceof MemoryFileUpload) {
MemoryFileUpload mem = (MemoryFileUpload) delegate;
checkSize(mem.buffer.length() + event.length(), maxSize, upload);
if (mem.buffer.length() + event.length() > limitSize) {
// Switch to disk file upload.
DiskFileUpload disk = new DiskFileUpload(vertx, upload, errorHandler);
// Initial push (mem + current buffer)
disk.push(mem.buffer.appendBuffer(event));
// No cleanup required for the memory based backend.
delegate = disk;
// the disk based implementation use a pump.
} else {
delegate.push(event);
}
}
}
}
);
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:45,代码来源:MixedFileUpload.java
示例4: FileUploadImpl
import io.vertx.core.http.HttpServerFileUpload; //导入依赖的package包/类
public FileUploadImpl(String uploadedFileName, HttpServerFileUpload upload) {
this.uploadedFileName = uploadedFileName;
this.upload = upload;
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:5,代码来源:FileUploadImpl.java
示例5: 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"));
}
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:14,代码来源:MixedFileUpload.java
示例6: DiskFileUpload
import io.vertx.core.http.HttpServerFileUpload; //导入依赖的package包/类
/**
* Creates an instance of {@link org.wisdom.framework.vertx.file.DiskFileUpload}.
*
* @param vertx the Vert.X instance
* @param upload the Vert.X file upload object
* @param errorHandler the error handler
*/
public DiskFileUpload(Vertx vertx, HttpServerFileUpload upload, Handler<Result> errorHandler) {
super(upload, errorHandler);
this.file = tempFile(upload);
this.vertx = vertx;
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:13,代码来源:DiskFileUpload.java
示例7: MemoryFileUpload
import io.vertx.core.http.HttpServerFileUpload; //导入依赖的package包/类
/**
* Creates an instance of {@link org.wisdom.framework.vertx.file.MemoryFileUpload}.
*
* @param upload the Vert.X file upload object
* @param errorHandler the error handler
*/
public MemoryFileUpload(HttpServerFileUpload upload, Handler<Result> errorHandler) {
super(upload, errorHandler);
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:11,代码来源:MemoryFileUpload.java
示例8: VertxFileUpload
import io.vertx.core.http.HttpServerFileUpload; //导入依赖的package包/类
/**
* Creates the {@link org.wisdom.framework.vertx.file.VertxFileUpload}.
*
* @param upload the {@link HttpServerFileUpload} that is uploaded.
* @param errorHandler the error handler.
*/
protected VertxFileUpload(HttpServerFileUpload upload, Handler<Result> errorHandler) {
this.upload = upload;
this.errorHandler = errorHandler;
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:11,代码来源:VertxFileUpload.java
注:本文中的io.vertx.core.http.HttpServerFileUpload类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论