@Override public String contentType() { return upload.contentType(); }
assertEquals("file", upload.name()); assertEquals("tmp-0.txt", upload.filename()); assertEquals("image/gif", upload.contentType()); String uploadedFileName; if (!streamToDisk) {
/** * @return the content type for the upload */ public String contentType() { String ret = delegate.contentType(); return ret; }
/** * @return the content type for the upload */ public String contentType() { String ret = delegate.contentType(); return ret; }
/** * Gets the file mime type as passed by the browser. * * @return the mime type of the file, {@literal null} is not set. */ @Override public String mimetype() { return upload.contentType(); }
@Override public String contentType() { return upload.contentType(); }
assertEquals("file", upload.name()); assertEquals("tmp-0.txt", upload.filename()); assertEquals("image/gif", upload.contentType()); String uploadedFileName; if (!streamToDisk) {
public YokeFileUpload(@NotNull final Vertx vertx, @NotNull final HttpServerFileUpload fileUpload, @NotNull String uploadDir) { this.fileSystem = vertx.fileSystem(); this.filename = fileUpload.filename(); this.name = fileUpload.name(); this.contentType = fileUpload.contentType(); this.contentTransferEncoding = fileUpload.contentTransferEncoding(); this.charset = fileUpload.charset(); this.size = fileUpload.size(); if (!uploadDir.endsWith(File.separator)) { uploadDir += File.separator; } this.path = uploadDir + UUID.randomUUID().toString(); }
private void testFileUploadFormMultipart(int size) throws Exception { Buffer content = Buffer.buffer(TestUtils.randomAlphaString(size)); vertx.fileSystem().writeFileBlocking(testFile.getPath(), content); server.requestHandler(req -> { req.setExpectMultipart(true); req.uploadHandler(upload -> { Buffer fileBuffer = Buffer.buffer(); assertEquals("file", upload.name()); assertEquals("test.txt", upload.filename()); assertEquals("text/plain", upload.contentType()); upload.handler(fileBuffer::appendBuffer); upload.endHandler(v -> assertEquals(content, fileBuffer)); }); req.endHandler(v -> { assertEquals("vert.x", req.getFormAttribute("toolkit")); assertEquals("jvm", req.getFormAttribute("runtime")); req.response().end(); }); }); startServer(); MultipartForm form = MultipartForm.create() .attribute("toolkit", "vert.x") .attribute("runtime", "jvm") .textFileUpload("file", testFile.getName(), testFile.getPath(), "text/plain"); HttpRequest<Buffer> builder = client.post("somepath"); builder.sendMultipartForm(form, onSuccess(resp -> complete())); await(); }