new release

This commit is contained in:
Page Asgardius 2022-12-31 10:16:44 -07:00
parent 697d2b8b07
commit 5dd93a01c5
7 changed files with 56 additions and 31 deletions

View file

@ -9,7 +9,7 @@ android {
applicationId "asgardius.page.s3manager"
minSdk 23
targetSdk 33
versionCode 56
versionCode 57
versionName "0.6.0"
setProperty("archivesBaseName", "s3-manager-$versionName")

View file

@ -52,8 +52,7 @@
<activity
android:name=".Downloader"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"
android:exported="false"
android:label="@string/download_file" />
android:exported="false" />
<activity
android:name=".CreateBucket"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"
@ -62,8 +61,7 @@
<activity
android:name=".Uploader"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"
android:exported="false"
android:label="@string/upload_button" />
android:exported="false" />
<activity
android:name=".ImageViewer"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"

View file

@ -79,6 +79,11 @@ public class Downloader extends AppCompatActivity {
style = getIntent().getBooleanExtra("style", false);
isfolder = getIntent().getBooleanExtra("isfolder", false);
prefix = getIntent().getStringExtra("prefix");
if(isfolder) {
getSupportActionBar().setTitle(getResources().getString(R.string.download_files));
} else {
getSupportActionBar().setTitle(getResources().getString(R.string.download_file));
}
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
fileDownload = (Button)findViewById(R.id.filedownload);
region = Region.getRegion(location);

View file

@ -23,12 +23,15 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.amazonaws.AbortedException;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
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.AbortMultipartUploadRequest;
import com.amazonaws.services.s3.model.AmazonS3Exception;
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest;
import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest;
import com.amazonaws.services.s3.model.InitiateMultipartUploadResult;
@ -87,6 +90,11 @@ public class Uploader extends AppCompatActivity {
style = getIntent().getBooleanExtra("style", false);
isfolder = getIntent().getBooleanExtra("isfolder", false);
prefix = getIntent().getStringExtra("prefix");
if(isfolder) {
getSupportActionBar().setTitle(getResources().getString(R.string.batch_upload_button));
} else {
getSupportActionBar().setTitle(getResources().getString(R.string.upload_button));
}
fprefix = (EditText)findViewById(R.id.fprefix);
fprefixlabel = (TextView) findViewById(R.id.fprefixlabel);
region = Region.getRegion(location);
@ -152,14 +160,14 @@ public class Uploader extends AppCompatActivity {
int treelevel = 0;
ArrayList<Integer> fileindex = new ArrayList<Integer>();
fileindex.add(0);
for (int i = 0; i < filelist.length; i++) {
for (int i = 0; i < filelist.length && !cancel; i++) {
filepath.add(filelist[i].getName());
if(filelist[i].isDirectory()) {
treelevel++;
fileindex.add(0);
document = filelist[i];
filelist = document.listFiles();
while (treelevel >= 1 && fileindex.get(treelevel) < filelist.length+1) {
while (treelevel >= 1 && fileindex.get(treelevel) < filelist.length+1 && !cancel) {
if(fileindex.get(treelevel) == filelist.length) {
fileindex.remove(treelevel);
document = document.getParentFile();
@ -214,9 +222,13 @@ public class Uploader extends AppCompatActivity {
mWakeLock.release();
//System.out.println("WakeLock released");
}
simpleProgressBar.setProgress(100);
if(!cancel) {
simpleProgressBar.setProgress(100);
}
//simpleProgressBar.setVisibility(View.INVISIBLE);
if (isfolder) {
if (cancel) {
fileUpload.setText(getResources().getString(R.string.upload_canceled));
} else if (isfolder) {
fileUpload.setText(getResources().getString(R.string.batch_upload_success));
} else {
fileUpload.setText(getResources().getString(R.string.upload_success));
@ -431,32 +443,40 @@ public class Uploader extends AppCompatActivity {
// Upload the file parts.
long fileOffset = 0;
for (int partNumber = 1; fileOffset < contentLength; ++partNumber) {
// Because the last part could be less than 5 MB, adjust the part size as needed.
partSize = Math.min(partSize, (contentLength - fileOffset));
try{
for (int partNumber = 1; fileOffset < contentLength && !cancel; ++partNumber) {
// Because the last part could be less than 5 MB, adjust the part size as needed.
partSize = Math.min(partSize, (contentLength - fileOffset));
// Create the request to upload a part.
UploadPartRequest uploadRequest = new UploadPartRequest()
.withBucketName(bucket)
.withKey(objectKey)
.withUploadId(initResponse.getUploadId())
.withPartNumber(partNumber)
.withFileOffset(fileOffset)
.withFile(file)
.withPartSize(partSize);
// Create the request to upload a part.
UploadPartRequest uploadRequest = new UploadPartRequest()
.withBucketName(bucket)
.withKey(objectKey)
.withUploadId(initResponse.getUploadId())
.withPartNumber(partNumber)
.withFileOffset(fileOffset)
.withFile(file)
.withPartSize(partSize);
// Upload the part and add the response's ETag to our list.
UploadPartResult uploadResult = s3client.uploadPart(uploadRequest);
//LOGGER.info("Uploading part {} of Object s3://{}/{}", partNumber, bucket, objectKey);
partETags.add(uploadResult.getPartETag());
// Upload the part and add the response's ETag to our list.
UploadPartResult uploadResult = s3client.uploadPart(uploadRequest);
//LOGGER.info("Uploading part {} of Object s3://{}/{}", partNumber, bucket, objectKey);
partETags.add(uploadResult.getPartETag());
fileOffset += partSize;
transfered++;
fileOffset += partSize;
transfered++;
}
// Complete the multipart upload.
CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(bucket, objectKey, initResponse.getUploadId(), partETags);
s3client.completeMultipartUpload(compRequest);
} catch (AbortedException | AmazonS3Exception e) {
e.printStackTrace();
AbortMultipartUploadRequest abort = new AbortMultipartUploadRequest(bucket, objectKey, initResponse.getUploadId());
s3client.abortMultipartUpload(abort);
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
//finish();
}
// Complete the multipart upload.
CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(bucket, objectKey, initResponse.getUploadId(), partETags);
s3client.completeMultipartUpload(compRequest);
}
private void calculateSize() {

View file

@ -11,6 +11,7 @@
<string name="bucket_name_empty">Se requiere un nombre para el bucket</string>
<string name="file_share">Compartir archivo</string>
<string name="download_file">Descargar archivo</string>
<string name="download_files">Descargar archivos</string>
<string name="cancel_download">Cancelar descarga</string>
<string name="download_success">Archivo descargado exitosamente</string>
<string name="upload_file_tobucket">Subir archivo en este bucket</string>

View file

@ -24,6 +24,7 @@
<string name="file_share">Share file</string>
<string name="file_external">Open in</string>
<string name="download_file">Download file</string>
<string name="download_files">Download files</string>
<string name="download_bucket">Download bucket content</string>
<string name="download_folder">Download folder content</string>
<string name="cancel_download">Cancel download</string>