Advertisement
Guest User

full_code_next_cloud

a guest
Apr 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. private void startUpload(File fileToUpload) {
  2.  
  3. File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path));
  4. File fileToUpload = upFolder.listFiles()[0];
  5. remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
  6. String mimeType = getString(R.string.sample_file_mimetype);
  7.  
  8. // Get the last modification date of the file from the file system
  9. Long timeStampLong = fileToUpload.lastModified() / 1000;
  10. String timeStamp = timeStampLong.toString();
  11.  
  12. UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), "Bariwala/" + remotePath, mimeType, timeStamp);
  13. uploadOperation.addDatatransferProgressListener(this);
  14. mHandler = new Handler();
  15. uploadOperation.execute(FileTransferClient.getFileTransferClient(ctx), CreateAdsActivity.this, mHandler);
  16.  
  17. }
  18.  
  19.  
  20. @Override
  21. public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
  22. if (!result.isSuccess()) {
  23. //Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show();
  24. Log.e(LOG_TAG, result.getLogMessage(), result.getException());
  25.  
  26. } else if (operation instanceof ReadRemoteFolderOperation) {
  27. //onSuccessfulRefresh((ReadRemoteFolderOperation)operation, result);
  28.  
  29. } else if (operation instanceof UploadRemoteFileOperation) {
  30. //onSuccessfulUpload((UploadRemoteFileOperation)operation, result);
  31. Log.v(LOG_TAG, result.getHttpPhrase() + " " + result.getLogMessage() + " " + result.getData() + " " +
  32.  
  33. CreateRemoteShareOperation oshare = new CreateRemoteShareOperation("Bariwala/" + remotePath, ShareType.PUBLIC_LINK, "",
  34. false, getString(R.string.password), 1);
  35. //oshare.setGetShareDetails(true);
  36. oshare.execute(FileTransferClient.getFileTransferClient(ctx)); //Getting error
  37.  
  38. } else if (operation instanceof RemoveRemoteFileOperation) {
  39. //onSuccessfulRemoteDeletion((RemoveRemoteFileOperation)operation, result);
  40.  
  41. } else if (operation instanceof DownloadRemoteFileOperation) {
  42. //onSuccessfulDownload((DownloadRemoteFileOperation)operation, result);
  43. Log.v(LOG_TAG, result.getHttpPhrase() + " " + result.getLogMessage() + " " + result.getData() + " " + result.getRedirectedLocation());
  44.  
  45. } else {
  46. //Toast.makeText(this, R.string.todo_operation_finished_in_success, Toast.LENGTH_SHORT).show();
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement