类org.apache.http.entity.mime.MultipartEntity源码实例Demo

下面列出了怎么用org.apache.http.entity.mime.MultipartEntity的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: quarkus-http   文件: MultiPartTestCase.java
@Test
public void testMultiPartIndividualFileToLarge() throws IOException {
    TestHttpClient client = new TestHttpClient();
    try {
        String uri = DefaultServer.getDefaultServerURL() + "/servletContext/3";
        HttpPost post = new HttpPost(uri);
        MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

        entity.addPart("formValue", new StringBody("myValue", "text/plain", StandardCharsets.UTF_8));
        entity.addPart("file", new FileBody(new File(MultiPartTestCase.class.getResource("uploadfile.txt").getFile())));

        post.setEntity(entity);
        HttpResponse result = client.execute(post);
        final String response = HttpClientUtils.readResponse(result);
        Assert.assertEquals("EXCEPTION: class java.lang.IllegalStateException", response);
    } finally {
        client.getConnectionManager().shutdown();
    }
}
 
源代码2 项目: neembuu-uploader   文件: MediaFireUploadPlugin.java
public static void fileUpload() throws IOException {
    HttpClient httpclient = new DefaultHttpClient();
    httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    HttpPost httppost = new HttpPost(postURL);
    File file = new File("d:/hai.html");
    System.out.println(ukeycookie);
    httppost.setHeader("Cookie", ukeycookie + ";" + skeycookie + ";" + usercookie);
    MultipartEntity mpEntity = new MultipartEntity();
    ContentBody cbFile = new FileBody(file);
    mpEntity.addPart("", cbFile);
    httppost.setEntity(mpEntity);
    System.out.println("Now uploading your file into mediafire...........................");
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity resEntity = response.getEntity();

    System.out.println(response.getStatusLine());
    if (resEntity != null) {
        System.out.println("Getting upload response key value..........");
        uploadresponsekey = EntityUtils.toString(resEntity);
        getUploadResponseKey();
        System.out.println("upload resoponse key " + uploadresponsekey);
    }
}
 
源代码3 项目: neembuu-uploader   文件: MixtureCloud.java
private void uploadMixtureCloud() throws Exception {
    uploadInitialising();
    responseString = NUHttpClientUtils.getData("https://www.mixturecloud.com/files", httpContext);
    uploadUrl = "http:" + StringUtils.stringBetweenTwoStrings(responseString, "urlUpload   : '", "',");
    NULogger.getLogger().log(Level.INFO, "uploadUrl is {0}", uploadUrl);
    
    httpPost = new NUHttpPost(uploadUrl);
    MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    mpEntity.addPart("cmd", new StringBody("upload"));
    mpEntity.addPart("target", new StringBody("mcm1_MA"));
    mpEntity.addPart("upload[]", createMonitoredFileBody());
    httpPost.setEntity(mpEntity);
    
    uploading();
    httpResponse = httpclient.execute(httpPost, httpContext);
    HttpEntity resEntity = httpResponse.getEntity();
    responseString = EntityUtils.toString(resEntity);
    //NULogger.getLogger().log(Level.INFO, "stringResponse : {0}", responseString);
    
    JSONObject jSonObject = new JSONObject(responseString);
    String webAccess = jSonObject.getJSONArray("file_data").getJSONObject(0).getString("web_access");
    downloadUrl += webAccess;
    
    downURL = downloadUrl;
}
 
源代码4 项目: neembuu-uploader   文件: WuploadUploaderPlugin.java
public static void fileUpload() throws IOException {
    HttpClient httpclient = new DefaultHttpClient();
    httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    file = new File("/home/vigneshwaran/dinesh.txt");
    HttpPost httppost = new HttpPost(postURL);
    httppost.setHeader("Cookie", langcookie + ";" + sessioncookie + ";" + mailcookie + ";" + namecookie + ";" + rolecookie + ";" + orderbycookie + ";" + directioncookie + ";");
    MultipartEntity mpEntity = new MultipartEntity();
    ContentBody cbFile = new FileBody(file);
    mpEntity.addPart("files[]", cbFile);
    httppost.setEntity(mpEntity);
    System.out.println("Now uploading your file into wupload...........................");
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity resEntity = response.getEntity();
    System.out.println(response.getStatusLine());
    if (response.getStatusLine().getStatusCode() == 302
            && response.getFirstHeader("Location").getValue().contains("upload/done/")) {

        System.out.println("Upload successful :)");
    } else {
        System.out.println("Upload failed :(");
    }

}
 
源代码5 项目: neembuu-uploader   文件: DivShareUploaderPlugin.java
private static void fileUpload() throws Exception {

        file = new File("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Sunset.jpg");
        httpclient = new DefaultHttpClient();
//http://upload3.divshare.com/cgi-bin/upload.cgi?sid=8ef15852c69579ebb2db1175ce065ba6

        HttpPost httppost = new HttpPost(downURL + "cgi-bin/upload.cgi?sid=" + sid);


        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        ContentBody cbFile = new FileBody(file);
        mpEntity.addPart("file[0]", cbFile);

        httppost.setEntity(mpEntity);
        System.out.println("executing request " + httppost.getRequestLine());
        System.out.println("Now uploading your file into divshare.com");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        System.out.println(response.getStatusLine());
        System.out.println(EntityUtils.toString(resEntity));

    }
 
private static void fileUpload() throws Exception {

        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(postURL);
        httppost.setHeader("Cookie", sidcookie);
        file = new File("h:/install.txt");
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        ContentBody cbFile = new FileBody(file);
        mpEntity.addPart("filepc", cbFile);
        mpEntity.addPart("server", new StringBody(server));
        httppost.setEntity(mpEntity);
        System.out.println("executing request " + httppost.getRequestLine());
        System.out.println("Now uploading your file into uploadbox.com");
        HttpResponse response = httpclient.execute(httppost);
        System.out.println(response.getStatusLine());
        uploadresponse = response.getLastHeader("Location").getValue();
        uploadresponse = getData(uploadresponse);
        downloadlink = parseResponse(uploadresponse, "name=\"loadlink\" id=\"loadlink\" class=\"text\" onclick=\"this.select();\" value=\"", "\"");
        deletelink = parseResponse(uploadresponse, "name=\"deletelink\" id=\"deletelink\" class=\"text\" onclick=\"this.select();\" value=\"", "\"");
        System.out.println("Download link " + downloadlink);
        System.out.println("deletelink : " + deletelink);
    }
 
源代码7 项目: neembuu-uploader   文件: GigaSize.java
public void fileUpload() throws Exception {
    httpPost = new NUHttpPost("http://www.gigasize.com/uploadie");
    MultipartEntity mpEntity = new MultipartEntity();
    mpEntity.addPart("UPLOAD_IDENTIFIER", new StringBody(uploadid));
    mpEntity.addPart("sid", new StringBody(sid));
    mpEntity.addPart("fileUpload1", createMonitoredFileBody());
    httpPost.setEntity(mpEntity);
    uploading();
    NULogger.getLogger().info("Now uploading your file into Gigasize...........................");
    HttpResponse response = httpclient.execute(httpPost, httpContext);
    HttpEntity resEntity = response.getEntity();
    NULogger.getLogger().info(response.getStatusLine().toString());
    if (resEntity != null) {
        sid = "";
        sid = EntityUtils.toString(resEntity);
        NULogger.getLogger().log(Level.INFO, "After upload sid value : {0}", sid);
    } else {
        throw new Exception("There might be a problem with your internet connection or GigaSize server problem. Please try after some time :(");
    }
}
 
源代码8 项目: neembuu-uploader   文件: ZippyShare.java
private void fileUpload() throws Exception {
    httpPost = new NUHttpPost(postURL);
    MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    mpEntity.addPart("Filename", new StringBody(file.getName()));
    mpEntity.addPart("notprivate", new StringBody("false"));
    mpEntity.addPart("folder", new StringBody("/"));
    mpEntity.addPart("Filedata", createMonitoredFileBody()); 
    httpPost.setHeader("Cookie", usercookie);
    httpPost.setEntity(mpEntity);
    uploading();
    NULogger.getLogger().info("Now uploading your file into zippyshare.com");
    httpResponse = httpclient.execute(httpPost);
    gettingLink();
    HttpEntity resEntity = httpResponse.getEntity();
    if (resEntity != null) {
        uploadresponse = EntityUtils.toString(resEntity);
        downloadlink = StringUtils.stringBetweenTwoStrings(uploadresponse, "value=\"http://", "\"");
        downloadlink = "http://" + downloadlink;
        NULogger.getLogger().log(Level.INFO, "Download Link : {0}", downloadlink);
        downURL=downloadlink;
        
    }else{
        throw new Exception("ZippyShare server problem or Internet connectivity problem");
    }

}
 
源代码9 项目: quarkus-http   文件: MultiPartTestCase.java
@Test
public void testMultiPartRequestWithAddedServlet() throws IOException {
    TestHttpClient client = new TestHttpClient();
    try {
        String uri = DefaultServer.getDefaultServerURL() + "/servletContext/added";
        HttpPost post = new HttpPost(uri);
        MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

        entity.addPart("formValue", new StringBody("myValue", "text/plain", StandardCharsets.UTF_8));
        entity.addPart("file", new FileBody(new File(MultiPartTestCase.class.getResource("uploadfile.txt").getFile())));

        post.setEntity(entity);
        HttpResponse result = client.execute(post);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        final String response = HttpClientUtils.readResponse(result);
        Assert.assertEquals("PARAMS:\n" +
                "name: formValue\n" +
                "filename: null\n" +
                "content-type: null\n" +
                "Content-Disposition: form-data; name=\"formValue\"\n" +
                "size: 7\n" +
                "content: myValue\n" +
                "name: file\n" +
                "filename: uploadfile.txt\n" +
                "content-type: application/octet-stream\n" +
                "Content-Disposition: form-data; name=\"file\"; filename=\"uploadfile.txt\"\n" +
                "Content-Type: application/octet-stream\n" +
                "size: 13\n" +
                "content: file contents\n", response);
    } finally {
        client.getConnectionManager().shutdown();
    }
}
 
源代码10 项目: neembuu-uploader   文件: RapidShare.java
public void fileUpload() throws Exception {
        httpPost = new NUHttpPost(postURL);
        MultipartEntity mpEntity = new MultipartEntity();
        mpEntity.addPart("sub", new StringBody("upload"));
        mpEntity.addPart("cookie", new StringBody(RapidShareAccount.getRscookie()));
        mpEntity.addPart("folder", new StringBody("0"));
        mpEntity.addPart("filecontent", createMonitoredFileBody());
        httpPost.setEntity(mpEntity);
        uploading();
        NULogger.getLogger().info("Now uploading your file into rs...........................");
        httpResponse = httpclient.execute(httpPost, httpContext);
        HttpEntity resEntity = httpResponse.getEntity();

        NULogger.getLogger().info(httpResponse.getStatusLine().toString());
        if (resEntity != null) {
            gettingLink();
            uploadresponse = EntityUtils.toString(resEntity);
            NULogger.getLogger().log(Level.INFO, "Actual response : {0}", uploadresponse);
            uploadresponse = uploadresponse.replace("COMPLETE\n", "");

//            downloadid=uploadresponse.substring(uploadresponse.indexOf("E")+1);
            downloadid = uploadresponse.substring(0, uploadresponse.indexOf(","));
            uploadresponse = uploadresponse.replace(downloadid + ",", "");
            filename = uploadresponse.substring(0, uploadresponse.indexOf(","));
            NULogger.getLogger().log(Level.INFO, "download id : {0}", downloadid);
//            filename=uploadresponse.substring(uploadresponse.indexOf(","));
//            filename=uploadresponse.substring(0, uploadresponse.indexOf(","));
            NULogger.getLogger().log(Level.INFO, "File name : {0}", filename);
            downloadlink = "http://rapidshare.com/files/" + downloadid + "/" + filename;
            NULogger.getLogger().log(Level.INFO, "Download Link :{0}", downloadlink);
            downURL = downloadlink;

            uploadFinished();
        }
    }
 
源代码11 项目: neembuu-uploader   文件: ScribdUploaderPlugin.java
private static void fileUpload() throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        // int Min = 1, Max = 10;
        //Min + (int)(Math.random() * ((Max - Min) + 1))
        //1+(int)(Math.random() * ((10 - 1) + 1))
        //1+(int)(Math.random() * 10)
//        int k = 1 + (int) (Math.random() * 10);a
        File f = new File("E:/Projects/NU/NeembuuUploader/test/neembuuuploader/test/plugins/BayFilesUploaderPlugin.java");

        HttpPost httppost = new HttpPost("http://api.scribd.com/api?method=docs.upload&api_key=5t8cd1k0ww3iupw31bb2a&Session_key=" + session_key);

        MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        FileBody bin = new FileBody(f);
        reqEntity.addPart("file", bin);

        httppost.setEntity(reqEntity);
        System.out.println("Now uploading your file into scribd........ Please wait......................");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();

        if (resEntity != null) {

            doc_id = EntityUtils.toString(resEntity);
            System.out.println(doc_id);
            if (doc_id.contains("stat=\"ok\"")) {
                doc_id = parseResponse(doc_id, "<doc_id>", "</doc_id>");
                System.out.println("doc id :" + doc_id);
            } else {
                throw new Exception("There might be problem with your internet connection or server error. Please try again some after time :(");
            }
        } else {
            throw new Exception("There might be problem with your internet connection or server error. Please try again some after time :(");
        }
    }
 
@Test
public void testFileUploadWithMediumFileSizeThresholdAndLargeFile() throws Exception {
    int fileSizeThreshold = 1000;
    DefaultServer.setRootHandler(new BlockingHandler(createInMemoryReadingHandler(fileSizeThreshold)));

    TestHttpClient client = new TestHttpClient();
    File file = new File("tmp_upload_file.txt");
    file.createNewFile();
    try {
        writeLargeFileContent(file, fileSizeThreshold * 2);

        HttpPost post = new HttpPost(DefaultServer.getDefaultServerURL() + "/path");
        MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

        entity.addPart("formValue", new StringBody("myValue", "text/plain", StandardCharsets.UTF_8));
        entity.addPart("file", new FileBody(file));

        post.setEntity(entity);
        HttpResponse result = client.execute(post);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        String resp = HttpClientUtils.readResponse(result);

        Map<String, String> parsedResponse = parse(resp);
        Assert.assertEquals("false", parsedResponse.get("in_memory"));
        Assert.assertEquals("tmp_upload_file.txt", parsedResponse.get("file_name"));
        Assert.assertEquals(DigestUtils.md5Hex(new FileInputStream(file)), parsedResponse.get("hash"));

    } finally {
        file.delete();
        client.getConnectionManager().shutdown();
    }
}
 
源代码13 项目: jmeter-bzm-plugins   文件: HttpUtils.java
/**
 * Create Post Request with FormBodyPart body
 */
public HttpPost createPost(String uri, LinkedList<FormBodyPart> partsList) {
    HttpPost postRequest = new HttpPost(uri);
    MultipartEntity multipartRequest = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    for (FormBodyPart part : partsList) {
        multipartRequest.addPart(part);
    }
    postRequest.setEntity(multipartRequest);
    return postRequest;
}
 
源代码14 项目: neembuu-uploader   文件: FileFactoryUploadPlugin.java
public static void fileUpload() throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://upload.filefactory.com/upload.php");
//        httppost.setHeader("Cookie", cookie + ";" + membershipcookie);
        MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        //reqEntity.addPart("string_field",new StringBody("field value"));
        File f = new File("/home/vigneshwaran/Documents/TNEB Online Payment 3.pdf");
        FileBody bin = new FileBody(f);
        reqEntity.addPart("Filedata", bin);
        System.out.println(URLDecoder.decode(membershipcookie, "UTF-8")); 
        
        reqEntity.addPart("cookie", new StringBody(URLDecoder.decode(membershipcookie, "UTF-8")));
        reqEntity.addPart("Filename", new StringBody(f.getName())); 
        reqEntity.addPart("folderViewhash", new StringBody("0")); 
        
//        reqEntity.addPart("upload", new StringBody("Submit Query"));
        httppost.setEntity(reqEntity);
        System.out.println("Now uploading your file into filefactory.com. Please wait......................");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        String page = "";
        if (resEntity != null) {
            page = EntityUtils.toString(resEntity);
            System.out.println("PAGE :" + page);
        }
        //http://www.filefactory.com/file/complete.php/6nseodiow47d/
        downloadlink = getData("http://www.filefactory.com/file/complete.php/" + page);
        
        downloadlink = downloadlink.substring(downloadlink.indexOf("<div class=\"innerText\">"));
        downloadlink = downloadlink.replace("<div class=\"innerText\">", "");
        downloadlink = downloadlink.substring(0, downloadlink.indexOf("</p>"));
        downloadlink = downloadlink.substring(downloadlink.indexOf("<p>"));
        downloadlink=downloadlink.replaceAll("<p>","");
        System.out.println("Download Link : " + downloadlink);
    }
 
源代码15 项目: neembuu-uploader   文件: UploadingDotCom.java
private void fileUpload() throws Exception {
    //httpClient = new DefaultHttpClient();
    httpPost = new NUHttpPost(postURL);
    
    MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    reqEntity.addPart("Filename", new StringBody(getFileName()));
    reqEntity.addPart("SID", new StringBody(sid));
    reqEntity.addPart("folder_id", new StringBody("0"));
    reqEntity.addPart("file", new StringBody(fileID));
    reqEntity.addPart("file", createMonitoredFileBody());
    reqEntity.addPart("upload", new StringBody("Submit Query"));
    httpPost.setEntity(reqEntity);
    uploading();
    NULogger.getLogger().info("Now uploading your file into uploading.com. Please wait......................");
    HttpResponse response = httpClient.execute(httpPost, httpContext);
    HttpEntity resEntity = response.getEntity();

    if (resEntity != null) {
        gettingLink();
        uploadresponse = EntityUtils.toString(resEntity);
        NULogger.getLogger().log(Level.INFO, "PAGE :{0}", uploadresponse);
        uploadresponse = StringUtils.stringBetweenTwoStrings(uploadresponse, "answer\":\"", "\"");
        downURL = downloadlink;

        uploadFinished();

    } else {
        throw new Exception("There might be a problem with your internet connection or server error. Please try after some time :(");
    }
}
 
源代码16 项目: neembuu-uploader   文件: UploadedDotTo.java
private void fileUpload() throws Exception {
        httpPost = new NUHttpPost(postURL);
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        mpEntity.addPart("Filename", new StringBody(file.getName()));
        mpEntity.addPart("Filedata", createMonitoredFileBody());
        httpPost.setEntity(mpEntity);
        NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
        NULogger.getLogger().info("Now uploading your file into uploaded.net");
        uploading();
        httpResponse = httpclient.execute(httpPost, httpContext);
        gettingLink();
        HttpEntity resEntity = httpResponse.getEntity();

        NULogger.getLogger().info(httpResponse.getStatusLine().toString());
        if (resEntity != null) {
            uploadresponse = EntityUtils.toString(resEntity);
        }
//  
        NULogger.getLogger().log(Level.INFO, "Upload response : {0}", uploadresponse);
        uploadresponse = uploadresponse.substring(0, uploadresponse.indexOf(","));
        // changed to a descriptive/long download link (user-requested-feature) //Paralytic (01-AUG-2014)
        downloadlink = "http://uploaded.net/file/" + uploadresponse + "/" + file.getName();
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
        downURL = downloadlink;

        uploadFinished();
    }
 
源代码17 项目: neembuu-uploader   文件: FileDenUploaderPlugin.java
private static void fileUpload() throws Exception {

        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://www.fileden.com/upload_old.php");
        httppost.setHeader("Cookie", cookies.toString());
        file = new File("C:\\Documents and Settings\\dinesh\\Desktop\\ImageShackUploaderPlugin.java");
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        ContentBody cbFile = new FileBody(file);
        mpEntity.addPart("Filename", new StringBody(file.getName()));
        mpEntity.addPart("action", new StringBody("upload"));
        mpEntity.addPart("upload_to", new StringBody(""));
        mpEntity.addPart("overwrite_option", new StringBody("overwrite"));
        mpEntity.addPart("thumbnail_size", new StringBody("small"));
        mpEntity.addPart("create_img_tags", new StringBody("1"));
        mpEntity.addPart("file0", cbFile);
        httppost.setEntity(mpEntity);
        System.out.println("executing request " + httppost.getRequestLine());
        System.out.println("Now uploading your file into fileden");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();


        System.out.println(response.getStatusLine());
        if (resEntity != null) {
            uploadresponse = EntityUtils.toString(resEntity);
        }


        System.out.println(uploadresponse);
        downloadlink = parseResponse(uploadresponse, "'link':'", "'");
        System.out.println("Download link : " + downloadlink);
        httpclient.getConnectionManager().shutdown();
    }
 
private static void fileUpload() throws IOException {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    System.out.println(postURL);
    System.out.println(ucookie);
    System.out.println(uid);
    HttpPost httppost = new HttpPost(postURL);
    httppost.setHeader("Cookie", ucookie);
    MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    File f = new File("h:/Rock Lee.jpg");
    reqEntity.addPart("UPLOAD_IDENTIFIER", new StringBody(uid));
    reqEntity.addPart("u", new StringBody(ucookie));
    FileBody bin = new FileBody(f);
    reqEntity.addPart("file_0", bin);
    reqEntity.addPart("service_1", new StringBody("1"));
    reqEntity.addPart("service_16", new StringBody("1"));
    reqEntity.addPart("service_7", new StringBody("1"));
    reqEntity.addPart("service_17", new StringBody("1"));
    reqEntity.addPart("service_9", new StringBody("1"));
    reqEntity.addPart("service_10", new StringBody("1"));
    reqEntity.addPart("remember_1", new StringBody("1"));
    reqEntity.addPart("remember_16", new StringBody("1"));
    reqEntity.addPart("remember_7", new StringBody("1"));
    reqEntity.addPart("remember_17", new StringBody("1"));
    reqEntity.addPart("remember_9", new StringBody("1"));
    reqEntity.addPart("remember_10", new StringBody("1"));
    httppost.setEntity(reqEntity);
    System.out.println("Now uploading your file into multiupload.com. Please wait......................");
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity resEntity = response.getEntity();

    if (resEntity != null) {
        uploadresponse = EntityUtils.toString(resEntity);
        System.out.println("Response :\n" + uploadresponse);
        uploadresponse = parseResponse(uploadresponse, "\"downloadid\":\"", "\"");
        downloadlink = "http://www.multiupload.com/" + uploadresponse;
        System.out.println("Download link : " + downloadlink);
    }
}
 
private static void fileUpload() throws IOException {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(postURL);
//        httppost.setHeader("Accept", "text/*");
//        httppost.setHeader("User-Agent", "Shockwave Flash");
//        httppost.setHeader("Connection", "Keep-Alive");
//        httppost.setHeader("Pragma", "no-cache");
        httppost.setHeader("Cookie", sidcookie + ";" + timecookie + ";" + cachecookie + ";" + ucookie);

        MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

        reqEntity.addPart("Filename", new StringBody(file.getName()));
        reqEntity.addPart("folder_id", new StringBody("0"));
        reqEntity.addPart("SID", new StringBody(sid));
        reqEntity.addPart("file", new StringBody(fileID));
        FileBody bin = new FileBody(file);
        reqEntity.addPart("file", bin);
        reqEntity.addPart("upload", new StringBody("Submit Query"));
        httppost.setEntity(reqEntity);
        System.out.println("Now uploading your file into uploading.com. Please wait......................");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();

        if (resEntity != null) {
            uploadresponse = EntityUtils.toString(resEntity);
            System.out.println("PAGE :" + uploadresponse);
            uploadresponse = parseResponse(uploadresponse, "answer\":\"", "\"");
        }
    }
 
源代码20 项目: neembuu-uploader   文件: FileSonicUploaderPlugin.java
public void fileUpload() throws Exception {
        HttpClient httpclient = new DefaultHttpClient();
        httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
        file = new File("/home/vigneshwaran/VIGNESH/dinesh.txt");
        HttpPost httppost = new HttpPost(postURL);
        httppost.setHeader("Cookie", langcookie + ";" + sessioncookie + ";" + mailcookie + ";" + namecookie + ";" + rolecookie + ";" + msgreadcookie + ";" + msgcheckcookie + ";");
        MultipartEntity mpEntity = new MultipartEntity();
        ContentBody cbFile = new FileBody(file);
        mpEntity.addPart("files[]", cbFile);
        httppost.setEntity(mpEntity);
        System.out.println("Now uploading your file into filesonic...........................");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        System.out.println(response.getStatusLine());
//        if (resEntity != null) {
//
//            String tmp = EntityUtils.toString(resEntity);
////            System.out.println("response : " + tmp);
//
//        }
        uploadresponse = response.getLastHeader("Location").getValue();
        System.out.println("Upload response URL : " + uploadresponse);
        uploadresponse = getData(uploadresponse);
        if (uploadresponse.contains("File was successfully uploaded")) {
            System.out.println("File was successfully uploaded :)");
        } else {
            throw new Exception("There might be a problem with your internet connecivity or server error. Please try after some time. :(");
        }
    }
 
源代码21 项目: neembuu-uploader   文件: Badongo.java
private void fileUpload() throws Exception {
        HttpClient httpclient = new DefaultHttpClient();
        if (badongoAccount.loginsuccessful) {
            postURL = "http://upload.badongo.com/mpu_upload.php";
        }
        HttpPost httppost = new HttpPost(postURL);
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        mpEntity.addPart("Filename", new StringBody(file.getName()));
        if (badongoAccount.loginsuccessful) {
            mpEntity.addPart("PHPSESSID", new StringBody(dataid));
        }
        mpEntity.addPart("Filedata", createMonitoredFileBody());
        httppost.setEntity(mpEntity);
        NULogger.getLogger().log(Level.INFO, "executing request {0}", httppost.getRequestLine());
        NULogger.getLogger().info("Now uploading your file into badongo.com");
        uploading();
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        //  uploadresponse = response.getLastHeader("Location").getValue();
        //NULogger.getLogger().log(Level.INFO, "Upload response : {0}", uploadresponse);
        NULogger.getLogger().info(response.getStatusLine().toString());
        if (resEntity != null) {
            uploadresponse = EntityUtils.toString(resEntity);
        }
//        if (resEntity != null) {
//            resEntity.consumeContent();
//        }
        NULogger.getLogger().log(Level.INFO, "res {0}", uploadresponse);


        httpclient.getConnectionManager().shutdown();
    }
 
private static void fileUpload() throws IOException {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(uploadURL);
        httppost.setHeader("Cookie", scookie);
        file = new File("/media/backup/Projects/NU/NeembuuUploader/test/neembuuuploader/test/plugins/DropBoxUploaderPlugin.java");
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        ContentBody cbFile = new FileBody(file);
//        mpEntity.addPart("Filename", new StringBody(file.getName()));

//        mpEntity.addPart("PHPSESSID", new StringBody(dataid));

        mpEntity.addPart("upload", cbFile);
        httppost.setEntity(mpEntity);
        System.out.println("executing request " + httppost.getRequestLine());
        System.out.println("Now uploading your file into speedyshare.com");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        //  uploadresponse = response.getLastHeader("Location").getValue();
        System.out.println("Upload response : " + EntityUtils.toString(response.getEntity()));
        System.out.println(response.getStatusLine());
//        if (resEntity != null) {
//            uploadresponse = EntityUtils.toString(resEntity);
//        }
//        if (resEntity != null) {
//            resEntity.consumeContent();
//        }
//        System.out.println("res " + uploadresponse);


        httpclient.getConnectionManager().shutdown();
    }
 
源代码23 项目: neembuu-uploader   文件: UpBoothUploaderPlugin.java
private static void fileUpload() throws Exception {

        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://upbooth.com/uploadHandler.php?r=upbooth.com&p=http?aff=1db2f3b654350bf4");
        httppost.addHeader("Cookie", fileHostingCookie);
        file = new File("c:/Dinesh/Naruto_Face.jpg");
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        ContentBody cbFile = new FileBody(file);
        String cookie = fileHostingCookie.substring(fileHostingCookie.indexOf("=") + 1);
        cookie = cookie.substring(0, cookie.indexOf(";"));
        System.out.println(cookie);

        mpEntity.addPart("=_sessionid", new StringBody(cookie));
        mpEntity.addPart("files[]", cbFile);
        httppost.setEntity(mpEntity);
        System.out.println("executing request " + httppost.getRequestLine());
        System.out.println("Now uploading your file into upbooth.com");
        HttpResponse response = httpclient.execute(httppost);
        //        HttpEntity resEntity = response.getEntity();
        String uploadresponse = EntityUtils.toString(response.getEntity());

        System.out.println(response.getStatusLine());
//        if (resEntity != null) {
//            uploadresponse = EntityUtils.toString(resEntity);
//        }
//  
        System.out.println("Upload response : " + uploadresponse);
        String downloadlink = parseResponse(uploadresponse, "\"url\":\"", "\"");
        downloadlink = downloadlink.replaceAll("\\\\", "");
        String deletelink = parseResponse(uploadresponse, "\"delete_url\":\"", "\"");
        deletelink = deletelink.replaceAll("\\\\", "");
        System.out.println("Download link : " + downloadlink);
        System.out.println("Delete link : " + deletelink);
    }
 
源代码24 项目: neembuu-uploader   文件: FileServe.java
public void fileUpload() throws Exception {

        uploading();
        httpPost = new NUHttpPost(postURL);

        MultipartEntity mpEntity = new MultipartEntity();

        mpEntity.addPart("files", createMonitoredFileBody());
        httpPost.setEntity(mpEntity);
        NULogger.getLogger().info("Now uploading your file into fileserve...........................");
        httpResponse = httpclient.execute(httpPost, httpContext);
        HttpEntity resEntity = httpResponse.getEntity();

        NULogger.getLogger().info(httpResponse.getStatusLine().toString());
        if (resEntity != null) {

            stringResponse = EntityUtils.toString(resEntity);
            NULogger.getLogger().log(Level.INFO, "upload response : {0}", stringResponse);
            gettingLink();
            String shortencode = StringUtils.stringBetweenTwoStrings(stringResponse, "\"shortenCode\":\"", "\"");
            String fileName = StringUtils.stringBetweenTwoStrings(stringResponse, "\"fileName\":\"", "\"");
            String deleteCode = StringUtils.stringBetweenTwoStrings(stringResponse, "\"deleteCode\":\"", "\"");
            downloadlink = "http://www.fileserve.com/file/" + shortencode + "/" + fileName;
            deletelink = "http://www.fileserve.com/file/" + shortencode + "/delete/" + deleteCode;
            NULogger.getLogger().log(Level.INFO, "Download Link : {0}", downloadlink);
            NULogger.getLogger().log(Level.INFO, "Delete Link : {0}", deletelink);
            downURL = downloadlink;
            delURL = deletelink;

        } else {
            throw new Exception("There might be a problem with your internet connection or server error. Please try again later :(");
        }
    }
 
源代码25 项目: neembuu-uploader   文件: BayFiles.java
private void fileUpload() throws Exception {

        HttpPost httpPost = new HttpPost(postURL);
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        mpEntity.addPart("file", createMonitoredFileBody());
        httpPost.setEntity(mpEntity);
        NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
        uploading();
        NULogger.getLogger().info("Now uploading your file into bayfiles.com");
        HttpResponse response = httpclient.execute(httpPost);
        gettingLink();
        uploadresponse = EntityUtils.toString(response.getEntity());

        NULogger.getLogger().info(response.getStatusLine().toString());

//  
//        NULogger.getLogger().log(Level.INFO, "Upload response : {0}", uploadresponse);
        jSonOjbject = new JSONObject(uploadresponse);
        downloadlink = jSonOjbject.getString("downloadUrl");
        deletelink = jSonOjbject.getString("deleteUrl");
        
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
        NULogger.getLogger().log(Level.INFO, "Delete link : {0}", deletelink);
        downURL = downloadlink;
        delURL = deletelink;

        uploadFinished();
    }
 
源代码26 项目: neembuu-uploader   文件: ShareSend.java
private boolean getUploadUrl() throws UnsupportedEncodingException, IOException, Exception{
    String contentType = FileUtils.getContentType(file);
    FileInputStream fis = new FileInputStream(file);
    //NULogger.getLogger().log(Level.INFO, "Content type: {0}", contentType);
    
    httpPost = new NUHttpPost("http://sharesend.com/api/get_upload_url");
    MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    mpEntity.addPart("name", new StringBody(file.getName()));
    mpEntity.addPart("content_type", new StringBody(contentType));
    mpEntity.addPart("size", new StringBody(Long.toString(file.length())));
    mpEntity.addPart("hash", new StringBody(DigestUtils.sha256Hex(fis)));
    httpPost.setEntity(mpEntity);
    NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
    httpResponse = httpclient.execute(httpPost, httpContext);
    
    stringResponse = EntityUtils.toString(httpResponse.getEntity());
    
    //FileUtils.saveInFile("ShareSend.html", stringResponse);
    
    jsonObject = new JSONObject(stringResponse);
    
    if(jsonObject.has("error")){
        //Handle errors
        status = UploadStatus.GETTINGERRORS;
        throw new Exception(jsonObject.getString("error"));
    }
    else{
        if(jsonObject.has("token")){
            gettingLink();
            uploadProgress.set(100);
            downURL = "http://sharesend.com/" + jsonObject.getString("token");
            return true;
        }
        else{
            uploadUrl = jsonObject.getString("upload_url");
        }
    }
    return false;
}
 
public static void fileUpload() throws IOException {

        File file = new File("/home/vigneshwaran/VIGNESH/nu-test5.txt");
        DefaultHttpClient httpclient = new DefaultHttpClient();

        UsernamePasswordCredentials upc = new UsernamePasswordCredentials("[email protected]", "");


        HttpPost httppost = new HttpPost("http://api.localhostr.com/file");
        try {
            httppost.addHeader(new BasicScheme().authenticate(upc, httppost));
        } catch (AuthenticationException ex) {
            Logger.getLogger(LocalhostrUploaderPlugin.class.getName()).log(Level.SEVERE, null, ex);
        }

        MultipartEntity mpEntity = new MultipartEntity();
        ContentBody cbFile = new FileBody(file);
        mpEntity.addPart("name", new StringBody(file.getName()));
        mpEntity.addPart("file", cbFile);


        httppost.setEntity(mpEntity);
        System.out.println("Now uploading your file into localhost...........................");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        System.out.println(response.getStatusLine());
        if (resEntity != null) {

            String tmp = EntityUtils.toString(resEntity);
            System.out.println(tmp);
            downloadlink = tmp.substring(tmp.indexOf("http:"));
            downloadlink = downloadlink.substring(0, downloadlink.indexOf("\""));
            System.out.println("download link : " + downloadlink);

        }
//           uploadresponse = response.getLastHeader("Location").getValue();
//        System.out.println("Upload response : " + uploadresponse);
    }
 
源代码28 项目: neembuu-uploader   文件: BitShare.java
@Override
public void run() {
    try {
        if (bitShareAccount.loginsuccessful) {
            httpContext = bitShareAccount.getHttpContext();
            
            if(bitShareAccount.isPremium()){
                maxFileSizeLimit = 1073741824l; //1024 MB
            }
            else{
                maxFileSizeLimit = 2147483648l; //2048 MB
            }
            
        } else {
            cookieStore = new BasicCookieStore();
            httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
            maxFileSizeLimit = 1073741824l; //1024 MB
        }

        if (file.length() > maxFileSizeLimit) {
            throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), host);
        }
        uploadInitialising();
        initialize();

        
        httpPost = new NUHttpPost(uploadURL);
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        mpEntity.addPart("APC_UPLOAD_PROGRESS", new StringBody(progressKey));
        mpEntity.addPart("APC_UPLOAD_USERGROUP", new StringBody(userGroupKey));
        mpEntity.addPart("UPLOAD_IDENTIFIER", new StringBody(uploadIdentifier));
        FormBodyPart customBodyPart = FormBodyPartUtils.createEmptyFileFormBodyPart("file[]", new StringBody(""));
        mpEntity.addPart(customBodyPart);
        mpEntity.addPart("file[]", createMonitoredFileBody());
        httpPost.setEntity(mpEntity);
        
        NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
        NULogger.getLogger().info("Now uploading your file into BitShare.com");
        uploading();
        httpResponse = httpclient.execute(httpPost, httpContext);
        final String location = httpResponse.getFirstHeader("Location").getValue();
        responseString = EntityUtils.toString(httpResponse.getEntity());
        responseString = NUHttpClientUtils.getData(location, httpContext);
 
        //Read the links
        gettingLink();
        //FileUtils.saveInFile("BitShare.html", responseString);
        
        doc = Jsoup.parse(responseString);
        downloadlink = doc.select("#filedetails input[type=text]").eq(1).val();
        deletelink = doc.select("#filedetails input[type=text]").eq(4).val();
        
        NULogger.getLogger().log(Level.INFO, "Delete link : {0}", deletelink);
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
        downURL = downloadlink;
        delURL = deletelink;
        
        uploadFinished();
    } catch(NUException ex){
        ex.printError();
        uploadInvalid();
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, e);

        uploadFailed();
    }
}
 
源代码29 项目: neembuu-uploader   文件: FileJoker.java
@Override
public void run() {
    try {
        if (fileJokerAccount.loginsuccessful) {
            httpContext = fileJokerAccount.getHttpContext();
            maxFileSizeLimit = 2097152000L; // 2,000 MB
        } else {
            host = "FileJoker.net";
            uploadInvalid();
            return;
        }

        if (file.length() > maxFileSizeLimit) {
            throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), host);
        }
        uploadInitialising();
        initialize();
        
        long uploadID;
        Random random = new Random();
        uploadID = Math.round(random.nextFloat() * Math.pow(10,12));
        uploadid_s = String.valueOf(uploadID);
        
        uploadURL = doc.select("#ff_file").attr("action");
        uploadURL += "/?X-Progress-ID=" + uploadid_s;
        //https://fs01.filejoker.net/upload/2/?X-Progress-ID=8426262479780
        
        httpPost = new NUHttpPost(uploadURL);
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        mpEntity.addPart("upload_type", new StringBody("file"));
        mpEntity.addPart("srv_id", new StringBody(srv_id));
        mpEntity.addPart("sess_id", new StringBody(sess_id));
        mpEntity.addPart("srv_tmp_url", new StringBody(srv_tmp_url));
        mpEntity.addPart("file_1", createMonitoredFileBody());
        mpEntity.addPart("tos", new StringBody("1"));
        mpEntity.addPart("submit_btn", new StringBody(""));
        httpPost.setEntity(mpEntity);
        
        NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
        NULogger.getLogger().info("Now uploading your file into FileJoker.net");
        uploading();
        httpResponse = httpclient.execute(httpPost, httpContext);
        responseString = EntityUtils.toString(httpResponse.getEntity());
        
        doc = Jsoup.parse(responseString);
        
        //Read the links
        gettingLink();
        upload_fn = doc.select("input[name=fn]").val();
        if (upload_fn != null) {
            httpPost = new NUHttpPost("https://filejoker.net/");
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            formparams.add(new BasicNameValuePair("fn", upload_fn));
            formparams.add(new BasicNameValuePair("op", "upload_result"));
            formparams.add(new BasicNameValuePair("st", "OK"));

            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
            httpPost.setEntity(entity);
            httpResponse = httpclient.execute(httpPost, httpContext);
            responseString = EntityUtils.toString(httpResponse.getEntity());
            
            doc = Jsoup.parse(responseString);
            //$("table").first().find("tr:nth-child(3)").find("td:nth-child(2)").find("a").attr("href");

            downloadlink = doc.select("table").first().select("tr:nth-child(3)").select("td:nth-child(2)").select("a").attr("href");
            deletelink = UploadStatus.NA.getLocaleSpecificString();

            NULogger.getLogger().log(Level.INFO, "Delete link : {0}", deletelink);
            NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
            downURL = downloadlink;
            delURL = deletelink;
            
            uploadFinished();
        }
    } catch(NUException ex){
        ex.printError();
        uploadInvalid();
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, e);

        uploadFailed();
    }
}
 
源代码30 项目: neembuu-uploader   文件: FilePost.java
@Override
public void run() {
    try {
        if (filePostAccount.loginsuccessful) {
            httpContext = filePostAccount.getHttpContext();
            sessionID = CookieUtils.getCookieValue(httpContext, "SID");
            
            if(filePostAccount.isPremium()){
                maxFileSizeLimit = 5368709120l; //5 GB
            }
            else{
                maxFileSizeLimit = 2147483648l; //2 GB
            }
            
        } else {
            uploadInvalid();
            return;
        }

        //Check file length
        if (file.length() > maxFileSizeLimit) {
            throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), host);
        }
        uploadInitialising();
        initialize();

        
        httpPost = new NUHttpPost(uploadURL);
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        
        mpEntity.addPart("Filename", new StringBody(file.getName()));
        mpEntity.addPart("SID", new StringBody(sessionID));
        mpEntity.addPart("file", createMonitoredFileBody());
        mpEntity.addPart("Upload", new StringBody("Submit Query"));
        httpPost.setEntity(mpEntity);
        
        NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
        NULogger.getLogger().info("Now uploading your file into FilePost.com");
        uploading();
        httpResponse = httpclient.execute(httpPost, httpContext);
        responseString = EntityUtils.toString(httpResponse.getEntity());
        

        final String answer = StringUtils.stringBetweenTwoStrings(responseString, "answer\":\"", "\"");
        
        //Read the links
        gettingLink();
        responseString = NUHttpClientUtils.getData("http://filepost.com/files/done/" + answer, httpContext);
        
        //FileUtils.saveInFile("FilePost.html", responseString);
        
        doc = Jsoup.parse(responseString);
        //downloadlink = doc.getElementById("down_link").val(); // Long
        downloadlink = doc.getElementById("short_down_link").val(); // Short
        deletelink = doc.getElementById("edit_link").val();
        
        NULogger.getLogger().log(Level.INFO, "Delete link : {0}", deletelink);
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
        downURL = downloadlink;
        delURL = deletelink;
        
        uploadFinished();
    } catch(NUException ex){
        ex.printError();
        uploadInvalid();
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, e);

        uploadFailed();
    }
}
 
 类所在包
 类方法
 同包方法