This commit is contained in:
Page Asgardius 2022-09-13 12:00:52 -07:00
parent da4eaa5873
commit b4bfa9e26e
5 changed files with 26 additions and 35 deletions

View file

@ -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();

View file

@ -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();
}
}

View file

@ -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());

View file

@ -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();

View file

@ -16,10 +16,10 @@
<string name="file_external">Open in</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="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="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="upload_success">File uploaded successfully</string>
<string name="create_bucket">Create new bucket</string>