first step
This commit is contained in:
parent
881eadc957
commit
9c45c4aaf0
9 changed files with 72 additions and 18 deletions
|
@ -164,7 +164,11 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
//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());
|
upload(Name.get(position).toString(), false);
|
||||||
|
|
||||||
|
} else if (menuItem.getTitle() == getResources().getString(R.string.upload_folder_tobucket)) {
|
||||||
|
//Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
|
upload(Name.get(position).toString(), true);
|
||||||
|
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.download_bucket)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.download_bucket)) {
|
||||||
//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();
|
||||||
|
@ -298,7 +302,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upload(String bucket) {
|
private void upload(String bucket, boolean isfolder) {
|
||||||
Intent intent = new Intent(this, Uploader.class);
|
Intent intent = new Intent(this, Uploader.class);
|
||||||
intent.putExtra("endpoint", endpoint);
|
intent.putExtra("endpoint", endpoint);
|
||||||
intent.putExtra("username", username);
|
intent.putExtra("username", username);
|
||||||
|
@ -307,6 +311,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
intent.putExtra("prefix", prefix);
|
intent.putExtra("prefix", prefix);
|
||||||
intent.putExtra("region", location);
|
intent.putExtra("region", location);
|
||||||
intent.putExtra("style", style);
|
intent.putExtra("style", style);
|
||||||
|
intent.putExtra("isfolder", isfolder);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -395,7 +395,10 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
//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();
|
upload(false);
|
||||||
|
} else if (menuItem.getTitle() == getResources().getString(R.string.upload_folder_here)) {
|
||||||
|
//Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
|
upload(true);
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.download_folder)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.download_folder)) {
|
||||||
//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();
|
||||||
download(Name.get(position).toString(), true);
|
download(Name.get(position).toString(), true);
|
||||||
|
@ -431,7 +434,10 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
download(Name.get(position).toString(), false);
|
download(Name.get(position).toString(), false);
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
|
} else 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();
|
upload(false);
|
||||||
|
} else if (menuItem.getTitle() == getResources().getString(R.string.upload_folder_here)) {
|
||||||
|
//Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
|
upload(true);
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.create_link)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.create_link)) {
|
||||||
share(prefix + Name.get(position).toString(), Name.get(position).toString(), Img.get(position).equals(R.drawable.audiofile) || Img.get(position).equals(R.drawable.videofile));
|
share(prefix + Name.get(position).toString(), Name.get(position).toString(), Img.get(position).equals(R.drawable.audiofile) || Img.get(position).equals(R.drawable.videofile));
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.object_info)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.object_info)) {
|
||||||
|
@ -645,7 +651,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upload() {
|
private void upload(boolean isfolder) {
|
||||||
Intent intent = new Intent(this, Uploader.class);
|
Intent intent = new Intent(this, Uploader.class);
|
||||||
intent.putExtra("endpoint", endpoint);
|
intent.putExtra("endpoint", endpoint);
|
||||||
intent.putExtra("username", username);
|
intent.putExtra("username", username);
|
||||||
|
@ -654,6 +660,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
intent.putExtra("prefix", prefix);
|
intent.putExtra("prefix", prefix);
|
||||||
intent.putExtra("region", location);
|
intent.putExtra("region", location);
|
||||||
intent.putExtra("style", style);
|
intent.putExtra("style", style);
|
||||||
|
intent.putExtra("isfolder", isfolder);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.amazonaws.auth.AWSCredentials;
|
import com.amazonaws.auth.AWSCredentials;
|
||||||
|
@ -49,6 +50,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
int progress;
|
int progress;
|
||||||
Uri fileuri, folder;
|
Uri fileuri, folder;
|
||||||
EditText fprefix;
|
EditText fprefix;
|
||||||
|
TextView fprefixlabel;
|
||||||
Region region;
|
Region region;
|
||||||
S3ClientOptions s3ClientOptions;
|
S3ClientOptions s3ClientOptions;
|
||||||
AWSCredentials myCredentials;
|
AWSCredentials myCredentials;
|
||||||
|
@ -59,7 +61,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
Intent intent;
|
Intent intent;
|
||||||
Button fileUpload;
|
Button fileUpload;
|
||||||
Thread uploadFile, uploadProgress;
|
Thread uploadFile, uploadProgress;
|
||||||
boolean style;
|
boolean style, isfolder;
|
||||||
boolean started = false;
|
boolean started = false;
|
||||||
long transfered = 0;
|
long transfered = 0;
|
||||||
private static final long MAX_SINGLE_PART_UPLOAD_BYTES = 5 * 1024 * 1024;
|
private static final long MAX_SINGLE_PART_UPLOAD_BYTES = 5 * 1024 * 1024;
|
||||||
|
@ -81,8 +83,10 @@ public class Uploader extends AppCompatActivity {
|
||||||
bucket = getIntent().getStringExtra("bucket");
|
bucket = getIntent().getStringExtra("bucket");
|
||||||
location = getIntent().getStringExtra("region");
|
location = getIntent().getStringExtra("region");
|
||||||
style = getIntent().getBooleanExtra("style", false);
|
style = getIntent().getBooleanExtra("style", false);
|
||||||
|
isfolder = getIntent().getBooleanExtra("isfolder", false);
|
||||||
prefix = getIntent().getStringExtra("prefix");
|
prefix = getIntent().getStringExtra("prefix");
|
||||||
fprefix = (EditText)findViewById(R.id.fprefix);
|
fprefix = (EditText)findViewById(R.id.fprefix);
|
||||||
|
fprefixlabel = (TextView) findViewById(R.id.fprefixlabel);
|
||||||
region = Region.getRegion(location);
|
region = Region.getRegion(location);
|
||||||
s3ClientOptions = S3ClientOptions.builder().build();
|
s3ClientOptions = S3ClientOptions.builder().build();
|
||||||
s3ClientOptions.setPathStyleAccess(style);
|
s3ClientOptions.setPathStyleAccess(style);
|
||||||
|
@ -133,11 +137,15 @@ public class Uploader extends AppCompatActivity {
|
||||||
//Your code goes here
|
//Your code goes here
|
||||||
//s3client.createBucket(bucket, location);
|
//s3client.createBucket(bucket, location);
|
||||||
//System.out.println(fkey);
|
//System.out.println(fkey);
|
||||||
|
if (isfolder) {
|
||||||
|
//Nothing for now
|
||||||
|
} else {
|
||||||
ufile = readContentToFile(fileuri);
|
ufile = readContentToFile(fileuri);
|
||||||
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, fprefix.getText().toString(), ufile);
|
putS3Object(bucket, fprefix.getText().toString(), ufile);
|
||||||
|
}
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -153,7 +161,11 @@ public class Uploader extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
simpleProgressBar.setProgress(100);
|
simpleProgressBar.setProgress(100);
|
||||||
//simpleProgressBar.setVisibility(View.INVISIBLE);
|
//simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||||
|
if (isfolder) {
|
||||||
|
fileUpload.setText(getResources().getString(R.string.batch_upload_success));
|
||||||
|
} else {
|
||||||
fileUpload.setText(getResources().getString(R.string.upload_success));
|
fileUpload.setText(getResources().getString(R.string.upload_success));
|
||||||
|
}
|
||||||
started = false;
|
started = false;
|
||||||
fileUpload.setEnabled(false);
|
fileUpload.setEnabled(false);
|
||||||
//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();
|
||||||
|
@ -253,11 +265,15 @@ public class Uploader extends AppCompatActivity {
|
||||||
private void performFileSearch(String messageTitle) {
|
private void performFileSearch(String messageTitle) {
|
||||||
//uri = Uri.parse("content://com.android.externalstorage.documents/document/home");
|
//uri = Uri.parse("content://com.android.externalstorage.documents/document/home");
|
||||||
intent = new Intent();
|
intent = new Intent();
|
||||||
|
if (isfolder) {
|
||||||
|
intent.setAction(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
|
} else {
|
||||||
intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
|
intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
//intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
//intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
||||||
//intent.putExtra("android.provider.extra.INITIAL_URI", uri);
|
//intent.putExtra("android.provider.extra.INITIAL_URI", uri);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
|
}
|
||||||
((Activity) this).startActivityForResult(intent, 100);
|
((Activity) this).startActivityForResult(intent, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +292,14 @@ 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());
|
||||||
|
if (isfolder) {
|
||||||
|
fprefix.setText(prefix);
|
||||||
|
fprefix.setHint(getResources().getString(R.string.upload_prefix));
|
||||||
|
fprefixlabel.setText(getResources().getString(R.string.upload_prefix));
|
||||||
|
fileUpload.setText(getResources().getString(R.string.batch_upload_button));
|
||||||
|
} else {
|
||||||
fprefix.setText(prefix+getDisplayName(fileuri));
|
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 {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/fprefixlabel"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/upload_key"
|
android:text="@string/upload_key"
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
android:id="@+id/upload_file"
|
android:id="@+id/upload_file"
|
||||||
android:title="@string/upload_file_tobucket" />
|
android:title="@string/upload_file_tobucket" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/upload_folder"
|
||||||
|
android:title="@string/upload_folder_tobucket" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/download_bucket"
|
android:id="@+id/download_bucket"
|
||||||
android:title="@string/download_bucket" />
|
android:title="@string/download_bucket" />
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
android:id="@+id/upload_file"
|
android:id="@+id/upload_file"
|
||||||
android:title="@string/upload_file_here" />
|
android:title="@string/upload_file_here" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/upload_folder"
|
||||||
|
android:title="@string/upload_folder_here" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/download_folder"
|
android:id="@+id/download_folder"
|
||||||
android:title="@string/download_folder" />
|
android:title="@string/download_folder" />
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
android:id="@+id/upload_file"
|
android:id="@+id/upload_file"
|
||||||
android:title="@string/upload_file_here" />
|
android:title="@string/upload_file_here" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/upload_folder"
|
||||||
|
android:title="@string/upload_folder_here" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/download_file"
|
android:id="@+id/download_file"
|
||||||
android:title="@string/download_file" />
|
android:title="@string/download_file" />
|
||||||
|
|
|
@ -18,9 +18,12 @@
|
||||||
<string name="feature_not_supported">Su dispositivo no es compatible con esta característica</string>
|
<string name="feature_not_supported">Su dispositivo no es compatible con esta característica</string>
|
||||||
<string name="file_path_fail">No se encuentra el uri del archivo</string>
|
<string name="file_path_fail">No se encuentra el uri del archivo</string>
|
||||||
<string name="upload_button">Subir archivo</string>
|
<string name="upload_button">Subir archivo</string>
|
||||||
|
<string name="batch_upload_button">Subir archivos</string>
|
||||||
<string name="upload_key">Nombre del objeto</string>
|
<string name="upload_key">Nombre del objeto</string>
|
||||||
|
<string name="upload_prefix">Prefijo de los objetos</string>
|
||||||
<string name="no_file_selected">Favor de seleccionar un archivo</string>
|
<string name="no_file_selected">Favor de seleccionar un archivo</string>
|
||||||
<string name="upload_success">Archivo subido exitosamente</string>
|
<string name="upload_success">Archivo subido exitosamente</string>
|
||||||
|
<string name="batch_upload_success">Archivos subidos exitosamente</string>
|
||||||
<string name="cancel_upload">Cancelar subida</string>
|
<string name="cancel_upload">Cancelar subida</string>
|
||||||
<string name="retry">Reintentar</string>
|
<string name="retry">Reintentar</string>
|
||||||
<string name="download_failed">Descarga fallida</string>
|
<string name="download_failed">Descarga fallida</string>
|
||||||
|
|
|
@ -34,9 +34,12 @@
|
||||||
<string name="feature_not_supported">Your device is not compatible with this feature</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="batch_upload_button">Upload files</string>
|
||||||
<string name="upload_key">Object name</string>
|
<string name="upload_key">Object name</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="batch_upload_success">Files uploaded successfully</string>
|
||||||
<string name="cancel_upload">Cancel Upload</string>
|
<string name="cancel_upload">Cancel Upload</string>
|
||||||
<string name="retry">Retry</string>
|
<string name="retry">Retry</string>
|
||||||
<string name="download_failed">Download failed</string>
|
<string name="download_failed">Download failed</string>
|
||||||
|
|
Loading…
Reference in a new issue