fix uploader
This commit is contained in:
parent
29ebb3d85b
commit
817155f3e3
1 changed files with 6 additions and 8 deletions
|
@ -4,6 +4,7 @@ import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -44,7 +45,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Uploader extends AppCompatActivity {
|
public class Uploader extends AppCompatActivity {
|
||||||
String username, password, endpoint, bucket, prefix, location, fkey;
|
String username, password, endpoint, bucket, prefix, location;
|
||||||
int progress;
|
int progress;
|
||||||
Uri fileuri, folder;
|
Uri fileuri, folder;
|
||||||
EditText fprefix;
|
EditText fprefix;
|
||||||
|
@ -93,7 +94,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
|
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
|
||||||
//Toast.makeText(Uploader.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(Uploader.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
performFileSearch("Select file to upload");
|
performFileSearch("Select file to upload");
|
||||||
fprefix.setText(prefix);
|
//fprefix.setText(prefix);
|
||||||
fileUpload.setOnClickListener(new View.OnClickListener(){
|
fileUpload.setOnClickListener(new View.OnClickListener(){
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -125,11 +126,6 @@ public class Uploader extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (fprefix.getText().toString().endsWith("/") || fprefix.getText().toString().equals("")) {
|
|
||||||
fkey = fprefix.getText().toString()+getDisplayName(fileuri);
|
|
||||||
} else {
|
|
||||||
fkey = fprefix.getText().toString()+"/"+getDisplayName(fileuri);
|
|
||||||
}
|
|
||||||
//System.out.println(fkey);
|
//System.out.println(fkey);
|
||||||
progress = 0;
|
progress = 0;
|
||||||
filesize = 0;
|
filesize = 0;
|
||||||
|
@ -141,7 +137,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
filesize = ufile.length();
|
filesize = ufile.length();
|
||||||
//PutObjectRequest request = new PutObjectRequest(bucket, fkey, ufile);
|
//PutObjectRequest request = new PutObjectRequest(bucket, fkey, ufile);
|
||||||
//upload = s3client.putObject(request);
|
//upload = s3client.putObject(request);
|
||||||
putS3Object(bucket, fkey, ufile);
|
putS3Object(bucket, fprefix.getText().toString(), ufile);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -265,6 +261,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
((Activity) this).startActivityForResult(intent, 100);
|
((Activity) this).startActivityForResult(intent, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, final Intent resultData) {
|
public void onActivityResult(int requestCode, int resultCode, final Intent resultData) {
|
||||||
// The ACTION_OPEN_DOCUMENT intent was sent with the request code OPEN_DIRECTORY_REQUEST_CODE.
|
// The ACTION_OPEN_DOCUMENT intent was sent with the request code OPEN_DIRECTORY_REQUEST_CODE.
|
||||||
|
@ -279,6 +276,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
if (resultData != null && resultData.getData() != null) {
|
if (resultData != null && resultData.getData() != null) {
|
||||||
fileuri = resultData.getData();
|
fileuri = resultData.getData();
|
||||||
System.out.println(fileuri.toString());
|
System.out.println(fileuri.toString());
|
||||||
|
fprefix.setText(prefix+getDisplayName(fileuri));
|
||||||
//System.out.println("File selected successfully");
|
//System.out.println("File selected successfully");
|
||||||
//System.out.println("content://com.android.externalstorage.documents"+file.getPath());
|
//System.out.println("content://com.android.externalstorage.documents"+file.getPath());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue