uploader
This commit is contained in:
parent
da4eaa5873
commit
b4bfa9e26e
5 changed files with 26 additions and 35 deletions
|
@ -128,8 +128,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
|
|
||||||
listbucket.start();
|
listbucket.start();
|
||||||
//listbucket list = new listbucket();
|
|
||||||
//list.execute("test");
|
|
||||||
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
|
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view, int position) {
|
public void onClick(View view, int position) {
|
||||||
|
@ -156,8 +155,8 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
// Toast message on menu item clicked
|
// Toast message on menu item clicked
|
||||||
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_tobucket)) {
|
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_tobucket)) {
|
||||||
Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
//upload(Name.get(position).toString(), false);
|
upload(Name.get(position).toString(), false);
|
||||||
|
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.create_bucket)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.create_bucket)) {
|
||||||
//upload();
|
//upload();
|
||||||
|
|
|
@ -39,14 +39,11 @@ public class ImageViewer extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Sending reference and data to Adapter
|
|
||||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||||
iv.setImageDrawable(thumb_d);
|
iv.setImageDrawable(thumb_d);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//System.out.println("tree "+treelevel);
|
|
||||||
//System.out.println("prefix "+prefix);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -58,7 +55,6 @@ public class ImageViewer extends AppCompatActivity {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,17 +153,6 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*for (Bucket bucket : buckets) {
|
|
||||||
//i++;
|
|
||||||
//System.out.println(bucket.getName());
|
|
||||||
Name.add(bucket.getName());
|
|
||||||
//Img.add(R.drawable.ic_launcher_foreground);
|
|
||||||
Img.add(R.drawable.videofile);
|
|
||||||
}*/
|
|
||||||
//System.out.println(Name);
|
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -259,8 +248,8 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
// Toast message on menu item clicked
|
// Toast message on menu item clicked
|
||||||
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
|
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
|
||||||
Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
//upload(false);
|
upload(false);
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) {
|
||||||
if (Name.size() == 1 && treelevel >= 1) {
|
if (Name.size() == 1 && treelevel >= 1) {
|
||||||
Toast.makeText(ObjectSelect.this, getResources().getString(R.string.only_item_onlist), Toast.LENGTH_SHORT).show();
|
Toast.makeText(ObjectSelect.this, getResources().getString(R.string.only_item_onlist), Toast.LENGTH_SHORT).show();
|
||||||
|
@ -285,8 +274,8 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
// Toast message on menu item clicked
|
// Toast message on menu item clicked
|
||||||
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
|
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
|
||||||
Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
//upload(false);
|
upload(false);
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.file_external)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.file_external)) {
|
||||||
try {
|
try {
|
||||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
|
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
|
||||||
|
|
|
@ -3,11 +3,9 @@ package asgardius.page.s3manager;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.storage.StorageManager;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -20,11 +18,12 @@ import com.amazonaws.regions.Region;
|
||||||
import com.amazonaws.services.s3.AmazonS3;
|
import com.amazonaws.services.s3.AmazonS3;
|
||||||
import com.amazonaws.services.s3.AmazonS3Client;
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
import com.amazonaws.services.s3.S3ClientOptions;
|
import com.amazonaws.services.s3.S3ClientOptions;
|
||||||
|
import com.amazonaws.services.s3.model.PutObjectResult;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.io.File;
|
||||||
|
|
||||||
public class Uploader extends AppCompatActivity {
|
public class Uploader extends AppCompatActivity {
|
||||||
String username, password, endpoint, bucket, prefix, location;
|
String username, password, endpoint, bucket, prefix, location, fkey;
|
||||||
boolean isfolder;
|
boolean isfolder;
|
||||||
Uri file, folder;
|
Uri file, folder;
|
||||||
EditText fprefix;
|
EditText fprefix;
|
||||||
|
@ -75,7 +74,12 @@ public class Uploader extends AppCompatActivity {
|
||||||
} else {
|
} else {
|
||||||
//Toast.makeText(CreateBucket.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(CreateBucket.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
//System.out.println(file.getPath());
|
//System.out.println(file.getPath());
|
||||||
System.out.println(fprefix.getText().toString()+filename[filename.length-1]);
|
if (fprefix.getText().toString().endsWith("/") || fprefix.getText().toString().equals("")) {
|
||||||
|
fkey = fprefix.getText().toString()+filename[filename.length-1];
|
||||||
|
} else {
|
||||||
|
fkey = fprefix.getText().toString()+"/"+filename[filename.length-1];
|
||||||
|
}
|
||||||
|
System.out.println(fkey);
|
||||||
Thread uploadFile = new Thread(new Runnable() {
|
Thread uploadFile = new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,13 +87,16 @@ public class Uploader extends AppCompatActivity {
|
||||||
try {
|
try {
|
||||||
//Your code goes here
|
//Your code goes here
|
||||||
//s3client.createBucket(bucket, location);
|
//s3client.createBucket(bucket, location);
|
||||||
|
System.out.println(fkey);
|
||||||
|
File ufile = new File(file.toString());
|
||||||
|
PutObjectResult upload = s3client.putObject(bucket, fkey, ufile);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Sending reference and data to Adapter
|
// Sending reference and data to Adapter
|
||||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.upload_success), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.upload_success), Toast.LENGTH_SHORT).show();
|
||||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
//simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//System.out.println("tree "+treelevel);
|
//System.out.println("tree "+treelevel);
|
||||||
|
@ -110,7 +117,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//simpleProgressBar.setVisibility(View.VISIBLE);
|
//simpleProgressBar.setVisibility(View.VISIBLE);
|
||||||
//uploadFile.start();
|
uploadFile.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +137,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||||
startActivityForResult(Intent.createChooser(intent, messageTitle), 100);
|
startActivityForResult(Intent.createChooser(intent, messageTitle), 100);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(Uploader.this, getResources().getString(R.string.file_choose_fail), Toast.LENGTH_SHORT).show();
|
Toast.makeText(Uploader.this, getResources().getString(R.string.feature_not_supported), Toast.LENGTH_SHORT).show();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +157,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
file = resultData.getData();
|
file = resultData.getData();
|
||||||
filename = file.getPath().split("/");
|
filename = file.getPath().split("/");
|
||||||
System.out.println("File selected successfully");
|
System.out.println("File selected successfully");
|
||||||
System.out.println("Prefix "+prefix);
|
System.out.println(file.toString());
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(Uploader.this, getResources().getString(R.string.file_path_fail), Toast.LENGTH_SHORT).show();
|
Toast.makeText(Uploader.this, getResources().getString(R.string.file_path_fail), Toast.LENGTH_SHORT).show();
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
<string name="file_external">Open in</string>
|
<string name="file_external">Open in</string>
|
||||||
<string name="upload_file_tobucket">Upload file to this bucket</string>
|
<string name="upload_file_tobucket">Upload file to this bucket</string>
|
||||||
<string name="upload_folder_tobucket">Upload folder to this bucket</string>
|
<string name="upload_folder_tobucket">Upload folder to this bucket</string>
|
||||||
<string name="file_choose_fail">Could not open file choose screen</string>
|
<string name="feature_not_supported">Your device is not compatible with this feature</string>
|
||||||
<string name="file_path_fail">File uri not found</string>
|
<string name="file_path_fail">File uri not found</string>
|
||||||
<string name="upload_button">Upload file</string>
|
<string name="upload_button">Upload file</string>
|
||||||
<string name="upload_prefix">Upload prefix</string>
|
<string name="upload_prefix">Object prefix</string>
|
||||||
<string name="no_file_selected">Please select a file</string>
|
<string name="no_file_selected">Please select a file</string>
|
||||||
<string name="upload_success">File uploaded successfully</string>
|
<string name="upload_success">File uploaded successfully</string>
|
||||||
<string name="create_bucket">Create new bucket</string>
|
<string name="create_bucket">Create new bucket</string>
|
||||||
|
|
Loading…
Reference in a new issue