Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. class uploadTask extends AsyncTask<String, Void, String> {
  2. public uploadTask(String filePathName,String host_2,String user_2,String pass_2)
  3. {
  4. filePath=filePathName;
  5. host_1=host_2;
  6. user_1=user_2;
  7. pass_1=pass_2;
  8. Toast.makeText(getBaseContext(),"FTP DATA RECEIVING:"+"HOST:"+host_2+" USERNAME:"+user_2+" PASS:"+pass_2,Toast.LENGTH_LONG).show();
  9. //hostName=host;
  10. }
  11. @Override
  12. protected String doInBackground(String... params) {
  13. try {
  14.  
  15. Toast.makeText(getBaseContext(),"Entered Do in Background Method to upload",Toast.LENGTH_SHORT).show();
  16. ftp_host = "ftp.photoshelter.com";//This is not the correct way. Supposed to get from Backendless table
  17. ftp_username = "brytest";//This is not the correct way. Supposed to get from Backendless table
  18. ftp_password = "passtest";//This is not the correct way. Supposed to get from Backendless table
  19. Toast.makeText(getBaseContext(),"HOST:"+ftp_host+" USERNAME:"+ftp_username+" PASS:"+ftp_password,Toast.LENGTH_LONG).show();
  20. news_agency = "news agency";
  21. easyFTP ftp = new easyFTP();
  22. ftp.connect(ftp_host, ftp_username, ftp_password);
  23. status = ftp.setWorkingDirectory("mem/images"); // if User say provided any Destination then Set it , otherwise
  24. // Upload will be stored on Default /root level on server
  25. String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
  26. String imageTimeStamped = ftp_username + "_" + timeStamp + ".png";
  27. FileInputStream is = new FileInputStream(imageFileLocation);
  28. //addPhotoGrapherInfo();
  29.  
  30. ftp.uploadFile(is, imageTimeStamped);
  31. System.out.println("Successfull ftp upload to " + ftp_host);
  32. Toast.makeText(getBaseContext(), "Photo uploading by ftp to " + ftp_host, Toast.LENGTH_LONG).show();
  33. //}
  34. //reset booleans
  35. //cameraPicTaken = false;
  36. //galleryImageSelected = false;
  37. //System.out.println("reset cameraPicTaken and galleryImageSelected");
  38. // }
  39. return new String("Upload Successful");
  40. }catch (Exception e){
  41. String t="Failure : " + e.getLocalizedMessage();
  42. return t;
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement