Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void startUpload(File fileToUpload) {
- File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path));
- File fileToUpload = upFolder.listFiles()[0];
- remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
- String mimeType = getString(R.string.sample_file_mimetype);
- // Get the last modification date of the file from the file system
- Long timeStampLong = fileToUpload.lastModified() / 1000;
- String timeStamp = timeStampLong.toString();
- UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), "Bariwala/" + remotePath, mimeType, timeStamp);
- uploadOperation.addDatatransferProgressListener(this);
- mHandler = new Handler();
- uploadOperation.execute(FileTransferClient.getFileTransferClient(ctx), CreateAdsActivity.this, mHandler);
- }
- @Override
- public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
- if (!result.isSuccess()) {
- //Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show();
- Log.e(LOG_TAG, result.getLogMessage(), result.getException());
- } else if (operation instanceof ReadRemoteFolderOperation) {
- //onSuccessfulRefresh((ReadRemoteFolderOperation)operation, result);
- } else if (operation instanceof UploadRemoteFileOperation) {
- //onSuccessfulUpload((UploadRemoteFileOperation)operation, result);
- Log.v(LOG_TAG, result.getHttpPhrase() + " " + result.getLogMessage() + " " + result.getData() + " " +
- CreateRemoteShareOperation oshare = new CreateRemoteShareOperation("Bariwala/" + remotePath, ShareType.PUBLIC_LINK, "",
- false, getString(R.string.password), 1);
- //oshare.setGetShareDetails(true);
- oshare.execute(FileTransferClient.getFileTransferClient(ctx)); //Getting error
- } else if (operation instanceof RemoveRemoteFileOperation) {
- //onSuccessfulRemoteDeletion((RemoveRemoteFileOperation)operation, result);
- } else if (operation instanceof DownloadRemoteFileOperation) {
- //onSuccessfulDownload((DownloadRemoteFileOperation)operation, result);
- Log.v(LOG_TAG, result.getHttpPhrase() + " " + result.getLogMessage() + " " + result.getData() + " " + result.getRedirectedLocation());
- } else {
- //Toast.makeText(this, R.string.todo_operation_finished_in_success, Toast.LENGTH_SHORT).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement