diff --git a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java
index 02a5608..645aebb 100644
--- a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java
+++ b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java
@@ -128,8 +128,7 @@ public class BucketSelect extends AppCompatActivity {
});
listbucket.start();
- //listbucket list = new listbucket();
- //list.execute("test");
+
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, int position) {
@@ -156,8 +155,8 @@ public class BucketSelect extends AppCompatActivity {
// Toast message on menu item clicked
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_tobucket)) {
- Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
- //upload(Name.get(position).toString(), false);
+ //Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
+ upload(Name.get(position).toString(), false);
} else if (menuItem.getTitle() == getResources().getString(R.string.create_bucket)) {
//upload();
diff --git a/app/src/main/java/asgardius/page/s3manager/ImageViewer.java b/app/src/main/java/asgardius/page/s3manager/ImageViewer.java
index c0ff71d..ef41057 100644
--- a/app/src/main/java/asgardius/page/s3manager/ImageViewer.java
+++ b/app/src/main/java/asgardius/page/s3manager/ImageViewer.java
@@ -39,14 +39,11 @@ public class ImageViewer extends AppCompatActivity {
@Override
public void run() {
- // Sending reference and data to Adapter
simpleProgressBar.setVisibility(View.INVISIBLE);
iv.setImageDrawable(thumb_d);
}
});
- //System.out.println("tree "+treelevel);
- //System.out.println("prefix "+prefix);
} catch (Exception e) {
e.printStackTrace();
@@ -58,7 +55,6 @@ public class ImageViewer extends AppCompatActivity {
finish();
}
});
- //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
finish();
}
}
diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
index 8fc7238..00acfc0 100644
--- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
+++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
@@ -153,17 +153,6 @@ public class ObjectSelect extends AppCompatActivity {
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() {
@Override
@@ -259,8 +248,8 @@ public class ObjectSelect extends AppCompatActivity {
// Toast message on menu item clicked
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
- Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
- //upload(false);
+ //Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
+ upload(false);
} else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) {
if (Name.size() == 1 && treelevel >= 1) {
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.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
- Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
- //upload(false);
+ //Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
+ upload(false);
} else if (menuItem.getTitle() == getResources().getString(R.string.file_external)) {
try {
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
diff --git a/app/src/main/java/asgardius/page/s3manager/Uploader.java b/app/src/main/java/asgardius/page/s3manager/Uploader.java
index 5786c44..d58775d 100644
--- a/app/src/main/java/asgardius/page/s3manager/Uploader.java
+++ b/app/src/main/java/asgardius/page/s3manager/Uploader.java
@@ -3,11 +3,9 @@ package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
-import android.os.storage.StorageManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@@ -20,11 +18,12 @@ import com.amazonaws.regions.Region;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
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 {
- String username, password, endpoint, bucket, prefix, location;
+ String username, password, endpoint, bucket, prefix, location, fkey;
boolean isfolder;
Uri file, folder;
EditText fprefix;
@@ -75,7 +74,12 @@ public class Uploader extends AppCompatActivity {
} else {
//Toast.makeText(CreateBucket.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
//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() {
@Override
@@ -83,13 +87,16 @@ public class Uploader extends AppCompatActivity {
try {
//Your code goes here
//s3client.createBucket(bucket, location);
+ System.out.println(fkey);
+ File ufile = new File(file.toString());
+ PutObjectResult upload = s3client.putObject(bucket, fkey, ufile);
runOnUiThread(new Runnable() {
@Override
public void run() {
// Sending reference and data to Adapter
- Toast.makeText(getApplicationContext(),getResources().getString(R.string.upload_success), Toast.LENGTH_SHORT).show();
- simpleProgressBar.setVisibility(View.INVISIBLE);
+ //Toast.makeText(getApplicationContext(),getResources().getString(R.string.upload_success), Toast.LENGTH_SHORT).show();
+ //simpleProgressBar.setVisibility(View.INVISIBLE);
}
});
//System.out.println("tree "+treelevel);
@@ -110,7 +117,7 @@ public class Uploader extends AppCompatActivity {
}
});
//simpleProgressBar.setVisibility(View.VISIBLE);
- //uploadFile.start();
+ uploadFile.start();
}
}
@@ -130,7 +137,7 @@ public class Uploader extends AppCompatActivity {
if (intent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(Intent.createChooser(intent, messageTitle), 100);
} 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();
}
}
@@ -150,7 +157,7 @@ public class Uploader extends AppCompatActivity {
file = resultData.getData();
filename = file.getPath().split("/");
System.out.println("File selected successfully");
- System.out.println("Prefix "+prefix);
+ System.out.println(file.toString());
} else {
Toast.makeText(Uploader.this, getResources().getString(R.string.file_path_fail), Toast.LENGTH_SHORT).show();
finish();
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6b88975..a46808e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -16,10 +16,10 @@
Open in
Upload file to this bucket
Upload folder to this bucket
- Could not open file choose screen
+ Your device is not compatible with this feature
File uri not found
Upload file
- Upload prefix
+ Object prefix
Please select a file
File uploaded successfully
Create new bucket