Пример #1
0
  private void fileUpload() throws Exception {
    httpPost = new NUHttpPost(uploadURL);

    MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

    mpEntity.addPart("akey", new StringBody(fileCloudAccount.getFileCloudAPIKey()));

    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 filecloud.io .....");
    uploading();
    httpResponse = httpclient.execute(httpPost);
    HttpEntity resEntity = httpResponse.getEntity();
    NULogger.getLogger().info(httpResponse.getStatusLine().toString());
    if (resEntity != null) {
      stringResponse = EntityUtils.toString(resEntity);
    }

    // Get JSONObject
    jSonObject = new JSONObject(stringResponse);
    String responseStatus = jSonObject.getString("status");

    if (!"ok".equals(responseStatus)) {
      // Handle errors
      throw new Exception("Error: " + jSonObject.getString("message"));
    }

    String downloadURL = "http://filecloud.io/" + jSonObject.getString("ukey");
    NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadURL);
    downURL = downloadURL;

    status = UploadStatus.UPLOADFINISHED;
  }
Пример #2
0
  @Override
  public void run() {
    try {

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

      addExtensions();

      // Check extension
      if (!FileUtils.checkFileExtension(allowedExtensions, file)) {
        throw new NUFileExtensionException(file.getName(), host);
      }

      uploadInitialising();

      httpPost = new NUHttpPost(uploadURL);
      MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
      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 AnonFiles.com");
      uploading();
      httpResponse = httpclient.execute(httpPost);
      responseString = EntityUtils.toString(httpResponse.getEntity());

      // Read the links
      gettingLink();
      jSonObject = new JSONObject(responseString);
      if (jSonObject.getString("status").equals("success")) {
        downloadlink = jSonObject.getString("url");
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
      } else {
        throw new Exception("Upload failed: " + jSonObject.getString("msg"));
      }

      downURL = downloadlink;

      uploadFinished();
    } catch (NUException ex) {
      ex.printError();
      uploadInvalid();
    } catch (Exception e) {
      Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, e);

      uploadFailed();
    }
  }
Пример #3
0
  @Override
  public void login() {
    loginsuccessful = false;
    try {
      initialize();

      NULogger.getLogger().info("Trying to log in to FileParadox.in");
      httpPost = new NUHttpPost("http://fileparadox.in");

      List<NameValuePair> formparams = new ArrayList<NameValuePair>();
      formparams.add(new BasicNameValuePair("op", "login"));
      formparams.add(new BasicNameValuePair("login", getUsername()));
      formparams.add(new BasicNameValuePair("password", getPassword()));

      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
      httpPost.setEntity(entity);
      httpResponse = httpclient.execute(httpPost, httpContext);
      NULogger.getLogger().info(httpResponse.getStatusLine().toString());
      Header lastHeader = httpResponse.getLastHeader("Location");

      if (lastHeader != null && lastHeader.getValue().contains("op=upload_form")) {
        EntityUtils.consume(httpResponse.getEntity());
        loginsuccessful = true;
        username = getUsername();
        password = getPassword();
        NULogger.getLogger().info("FileParadox.in login successful!");

      } else {
        // Get error message
        responseString = EntityUtils.toString(httpResponse.getEntity());
        // FileUtils.saveInFile("FileParadoxAccount.html", responseString);
        Document doc = Jsoup.parse(responseString);
        String error = doc.select(".err").first().text();

        if ("Incorrect Login or Password".equals(error)) {
          throw new NUInvalidLoginException(getUsername(), HOSTNAME);
        }

        // Generic exception
        throw new Exception("Login error: " + error);
      }
    } catch (NUException ex) {
      resetLogin();
      ex.printError();
      AccountsManager.getInstance().setVisible(true);
    } catch (Exception e) {
      resetLogin();
      NULogger.getLogger().log(Level.SEVERE, "{0}: {1}", new Object[] {getClass().getName(), e});
      JOptionPane.showMessageDialog(
          NeembuuUploader.getInstance(),
          "<html>" + TranslationProvider.get("neembuuuploader.accounts.loginerror") + "</html>",
          HOSTNAME,
          JOptionPane.WARNING_MESSAGE);
      AccountsManager.getInstance().setVisible(true);
    }
  }
Пример #4
0
  /** Upload with normal uploader. */
  public void normalUpload() throws IOException, Exception {
    String uploadPostUrl;
    NUHttpPost httppost;
    HttpResponse response;
    String reqResponse;

    uploadPostUrl = "https://upload.firedrive.com/web";

    // Getting vars
    final String getUrl = "http://www.firedrive.com/upload?_=" + System.currentTimeMillis();
    reqResponse = NUHttpClientUtils.getData(getUrl, httpContext);
    final String vars = StringUtils.stringBetweenTwoStrings(reqResponse, "return '", "'");

    NULogger.getLogger().log(Level.INFO, "getUrl: {0}", getUrl);
    NULogger.getLogger().log(Level.INFO, "vars: {0}", vars);

    // Start the upload
    uploading();

    httppost = new NUHttpPost(uploadPostUrl);
    MultipartEntity mpEntity = new MultipartEntity();
    mpEntity.addPart("name", new StringBody(file.getName()));
    mpEntity.addPart("vars", new StringBody(vars));
    mpEntity.addPart("target_folder", new StringBody("0"));
    mpEntity.addPart("target_group", new StringBody("0"));
    mpEntity.addPart("file", createMonitoredFileBody());
    httppost.setEntity(mpEntity);
    response = httpclient.execute(httppost, httpContext);
    reqResponse = EntityUtils.toString(response.getEntity());

    JSONObject jSonObject = new JSONObject(reqResponse);

    if (jSonObject.getString("result").equals("success")) {
      // Now we can read the link
      gettingLink();
      downURL = "http://www.firedrive.com/file/" + jSonObject.getString("id");
      NULogger.getLogger().log(Level.INFO, "Download URL: {0}", downURL);
    } else {
      // Handle errors
      NULogger.getLogger().info(reqResponse);
      throw new Exception("Error in firedrive.com. Take a look to last jSonObject!");
    }
  }
Пример #5
0
  @Override
  public void login() {
    loginsuccessful = false;
    try {
      initialize();

      NULogger.getLogger().info("Trying to log in to bayfiles.com");
      httpPost = new NUHttpPost("http://bayfiles.net/ajax_login");
      List<NameValuePair> formparams = new ArrayList<NameValuePair>();
      formparams.add(new BasicNameValuePair("action", "login"));
      formparams.add(new BasicNameValuePair("username", getUsername()));
      formparams.add(new BasicNameValuePair("password", getPassword()));

      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
      httpPost.setEntity(entity);

      httpResponse = httpclient.execute(httpPost, httpContext);
      stringResponse = EntityUtils.toString(httpResponse.getEntity());

      // NULogger.getLogger().log(Level.INFO, "BayFiles.com stringResponse: {0}", stringResponse);

      jSonOjbject = new JSONObject(stringResponse);

      if (jSonOjbject.has("reload")) {
        loginsuccessful = true;
        username = getUsername();
        password = getPassword();
        NULogger.getLogger().info("Bayfiles.com login succeeded :)");
      } else {
        String error = jSonOjbject.getString("error");

        if ("Login failed. Please try again".equals(error)) {
          throw new NUInvalidLoginException(getUsername(), HOSTNAME);
        }

        // Generic exception
        throw new Exception("Login error: " + error);
      }

    } catch (NUException ex) {
      resetLogin();
      ex.printError();
      AccountsManager.getInstance().setVisible(true);
    } catch (Exception e) {
      resetLogin();
      NULogger.getLogger().log(Level.SEVERE, "{0}: {1}", new Object[] {getClass().getName(), e});
      JOptionPane.showMessageDialog(
          NeembuuUploader.getInstance(),
          "<html>" + TranslationProvider.get("neembuuuploader.accounts.loginerror") + "</html>",
          HOSTNAME,
          JOptionPane.WARNING_MESSAGE);
      AccountsManager.getInstance().setVisible(true);
    }
  }
Пример #6
0
  @Override
  public void run() {
    try {
      if (slingFileAccount.loginsuccessful) {
        host = slingFileAccount.username + " | SlingFile.com";
        httpContext = slingFileAccount.getHttpContext();
      } else {
        host = "SlingFile.com";
        cookieStore = new BasicCookieStore();
        httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
      }

      if (file.length() > fileSizeLimit) {
        throw new NUMaxFileSizeException(
            fileSizeLimit, file.getName(), slingFileAccount.getHOSTNAME());
      }
      uploadInitialising();
      initialize();

      httpPost = new NUHttpPost(postURL);
      MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
      mpEntity.addPart("X-Progress-ID", new StringBody(progressID));
      mpEntity.addPart("uFileID", new StringBody(progressID));
      mpEntity.addPart("uid", new StringBody(encUserID));
      if (slingFileAccount.loginsuccessful) {
        mpEntity.addPart("folderid", new StringBody("0"));
      }
      mpEntity.addPart("ssd", new StringBody(ssd));
      mpEntity.addPart("Filename", new StringBody(file.getName()));
      mpEntity.addPart("name", new StringBody(file.getName()));
      mpEntity.addPart("Upload", new StringBody("Submit Query"));
      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 slingfile.com");
      uploading();
      HttpResponse response = httpclient.execute(httpPost, httpContext);
      stringResponse = EntityUtils.toString(response.getEntity());

      if ("done".equals(stringResponse)) {
        NULogger.getLogger().log(Level.INFO, "upload done!");

        gettingLink();
        httpGet = new NUHttpGet(URILink);
        httpResponse = httpclient.execute(httpGet, httpContext);

        stringResponse = EntityUtils.toString(httpResponse.getEntity());
        // FileUtils.saveInFile("SlingFile.com.html", stringResponse);
        Document doc = Jsoup.parse(stringResponse);
        downloadlink =
            doc.select("div#container div#mainContent fieldset table tbody tr td input")
                .first()
                .val();
        deletelink =
            doc.select("div#container div#mainContent fieldset table tbody tr td input")
                .eq(3)
                .val();

        NULogger.getLogger().log(Level.INFO, "Delete link : {0}", deletelink);
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
        downURL = downloadlink;
        delURL = deletelink;
      } else {
        throw new Exception("Upload isn't good.");
      }

      uploadFinished();
    } catch (Exception e) {
      Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, e);

      uploadFailed();
    }
  }