Examples of FilePart


Examples of org.apache.commons.httpclient.methods.multipart.FilePart

        PostMethod method = new PostMethod();
        byte[] content = "Hello".getBytes();
        MultipartRequestEntity entity = new MultipartRequestEntity(
            new Part[] {
                new FilePart(
                    "param1",
                    new ByteArrayPartSource("filename.txt", content),
                    "text/plain",
                    "ISO-8859-1") },
            method.getParams());
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.FilePart

    // ----------------------------------------------------------------- Tests

    public void testFilePartResendsFileData() throws Exception {
        File file = createTempTestFile();
        FilePart part = new FilePart(NAME, file);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp1 = stream.toString();
        stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp2 = stream.toString();
        file.delete();
        assertEquals(resp1, resp2);
    }
View Full Code Here

Examples of org.asynchttpclient.multipart.FilePart

    public void testUnauthorizedWhileUploading() throws Exception {
        File file = createTempFile(1024 * 1024);

        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Response response = client.preparePut(getTargetUrl()).addBodyPart(new FilePart("test", file, "application/octet-stream", UTF_8)).execute()
                    .get();
            assertEquals(response.getStatusCode(), 401);
        } finally {
            client.close();
        }
View Full Code Here

Examples of play.mvc.Http.MultipartFormData.FilePart

    @BodyParser.Of(BodyParser.MultipartFormData.class)
    public Result create() {
        String path = getRefererPath();
        MultipartFormData body = request().body().asMultipartFormData();
        FilePart bundle = body.getFile("bundle");
        if (bundle != null) {
            CreateBundleRequest cbr;
            try {
                File file = bundle.getFile();
                String bundleContents = Files.toString(file, StandardCharsets.UTF_8);
                cbr = Json.fromJson(Json.parse(bundleContents), CreateBundleRequest.class);
            } catch (IOException e) {
                Logger.error("Could not parse uploaded bundle: " + e);
                flash("error", "The uploaded bundle could not be applied: does it have the right format?");
View Full Code Here

Examples of play.mvc.Http.MultipartFormData.FilePart

    @Override
    protected Result doExecute() throws DAOException, PartakeException {
        UserEx user = ensureLogin();
        ensureValidSessionToken();

        FilePart filePart = request().body().asMultipartFormData().getFile("file");
        if (filePart == null)
            return renderInvalid(UserErrorCode.INVALID_NOIMAGE);

        File file = filePart.getFile();
        String contentType = filePart.getContentType();

        if (file == null)
            return renderInvalid(UserErrorCode.INVALID_NOIMAGE);
        if (contentType == null)
            return renderInvalid(UserErrorCode.INVALID_IMAGE_CONTENTTYPE);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.