From a11ca08d6cb1d9a3b76cad20370177a7ea6bcd3c Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sat, 17 Sep 2022 15:46:42 -0700 Subject: [PATCH 001/224] new release --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8ecca02..287a81e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Current feature list * Delete folders * File upload * File download +* pdf file reader using user provided pdf.js server Planned feature list @@ -23,6 +24,8 @@ Planned feature list This app is a work in progress, so it have some bugs that need to be fixed +You need to setup a pdf.js server to use pdf viewer. Just download latest version from official website and upload to any web server with ssl on same root domain than S3 server (can be same subdomain or a different one). Then set url to pdfjs root folder like https://example.com/pdfjs-dist + Supported languages * English -- 2.39.5 From c0f5d483b7ee3d1bd43678a51d7234b55abb05f9 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sat, 17 Sep 2022 18:54:54 -0700 Subject: [PATCH 002/224] update readme --- README.md | 2 +- .../main/java/asgardius/page/s3manager/ObjectSelect.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 287a81e..b9dae05 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Known supported providers * Amazon Web Services * Scaleway Elements -* Oracle Cloud +* Oracle Cloud (partial) * MinIO Known not supported providers diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java index f3b53f2..abc809c 100644 --- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java @@ -66,7 +66,11 @@ public class ObjectSelect extends AppCompatActivity { region = Region.getRegion(location); s3ClientOptions = S3ClientOptions.builder().build(); myCredentials = new BasicAWSCredentials(username, password); - s3client = new AmazonS3Client(myCredentials, region); + try { + s3client = new AmazonS3Client(myCredentials, region); + } catch (Exception e) { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + } s3client.setEndpoint(endpoint); if (!endpoint.contains(getResources().getString(R.string.aws_endpoint))) { s3ClientOptions.setPathStyleAccess(true); -- 2.39.5 From 568352bde5ea2231dcfe636069f5669628ccc910 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sun, 18 Sep 2022 05:50:19 -0700 Subject: [PATCH 003/224] update about.htm --- app/src/main/assets/about.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/about.htm b/app/src/main/assets/about.htm index 7ba4b90..37ada69 100644 --- a/app/src/main/assets/about.htm +++ b/app/src/main/assets/about.htm @@ -17,7 +17,7 @@

This software released under GNU General Public License 3

You can find source code at https://patrice.asgardius.company/gitea/asgardius/s3manager
- You need to setup a pdf.js server to use pdf viewer. Just download latest version from official website and upload to any web server with ssl on same root domain than S3 server (can be same subdomain or a different one). Then set url to pdfjs root folder like https://example.com/pdfjs-dist + You need to setup a pdf.js server to use pdf viewer. Just download latest version from official website and upload to any web server with ssl on same root domain than S3 server (can be same subdomain or a different one in some cases). Then set url to pdfjs root folder like https://example.com/pdfjs-dist
You can find technical support on official forum https://forum.asgardius.company/t/s3-manager

-- 2.39.5 From 89af00ba9890fba6aa5e564cc08b674f6c90988e Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sun, 18 Sep 2022 10:37:32 -0700 Subject: [PATCH 004/224] file sharing backend --- app/src/main/AndroidManifest.xml | 3 + .../page/s3manager/ObjectSelect.java | 25 ++--- .../java/asgardius/page/s3manager/Share.java | 94 +++++++++++++++++++ app/src/main/res/layout/activity_share.xml | 9 ++ 4 files changed, 116 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/asgardius/page/s3manager/Share.java create mode 100644 app/src/main/res/layout/activity_share.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6a5e6f5..894774b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,9 @@ android:supportsRtl="true" android:theme="@style/Theme.AsgardiusS3Manager" tools:targetApi="31"> + = 1) { @@ -383,14 +377,15 @@ public class ObjectSelect extends AppCompatActivity { private void share(String object) { - try { - - Intent shareIntent = new Intent(Intent.ACTION_VIEW); - shareIntent.setData(Uri.parse(object)); - startActivity(Intent.createChooser(shareIntent, "choose one")); - } catch(Exception e) { - Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); - } + Intent intent = new Intent(this, Share.class); + //treelevel ++; + intent.putExtra("endpoint", endpoint); + intent.putExtra("username", username); + intent.putExtra("password", password); + intent.putExtra("bucket", bucket); + intent.putExtra("object", object); + intent.putExtra("region", location); + startActivity(intent); } diff --git a/app/src/main/java/asgardius/page/s3manager/Share.java b/app/src/main/java/asgardius/page/s3manager/Share.java new file mode 100644 index 0000000..5a01179 --- /dev/null +++ b/app/src/main/java/asgardius/page/s3manager/Share.java @@ -0,0 +1,94 @@ +package asgardius.page.s3manager; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.widget.Toast; + +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.GeneratePresignedUrlRequest; + +import java.net.URL; +import java.util.Calendar; +import java.util.Date; + +public class Share extends AppCompatActivity { + String username, password, endpoint, bucket, object, location; + Region region; + S3ClientOptions s3ClientOptions; + AWSCredentials myCredentials; + AmazonS3 s3client; + Calendar mycal; + + public static String URLify(String str) { + str = str.trim(); + int length = str.length(); + int trueL = length; + if(str.contains(" ")) { + for(int i = 0; i < length; i++) { + if(str.charAt(i) == ' ') { + trueL = trueL + 2; + } + } + char[] oldArr = str.toCharArray(); + char[] newArr = new char[trueL]; + int x = 0; + for(int i = 0; i < length; i++) { + if(oldArr[i] == ' ') { + newArr[x] = '%'; + newArr[x+1] = '2'; + newArr[x+2] = '0'; + x += 3; + } else { + newArr[x] = oldArr[i]; + x++; + } + } + str = new String(newArr, 0, trueL); + } + return str; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_share); + mycal = Calendar.getInstance(); + endpoint = getIntent().getStringExtra("endpoint"); + username = getIntent().getStringExtra("username"); + password = getIntent().getStringExtra("password"); + bucket = getIntent().getStringExtra("bucket"); + location = getIntent().getStringExtra("region"); + object = getIntent().getStringExtra("object"); + region = Region.getRegion(location); + s3ClientOptions = S3ClientOptions.builder().build(); + myCredentials = new BasicAWSCredentials(username, password); + try { + s3client = new AmazonS3Client(myCredentials, region); + } catch (Exception e) { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + } + s3client.setEndpoint(endpoint); + if (!endpoint.contains(getResources().getString(R.string.aws_endpoint))) { + s3ClientOptions.setPathStyleAccess(true); + } + s3client.setS3ClientOptions(s3ClientOptions); + mycal.set(Calendar.YEAR, 2022); + mycal.set(Calendar.MONTH, 8); + mycal.set(Calendar.DATE, 18); + mycal.set(Calendar.HOUR, 14); + mycal.set(Calendar.MINUTE, 15); + mycal.set(Calendar.SECOND, 28); + Date expiration = mycal.getTime(); + System.out.println(expiration); + + GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration); + URL objectURL = s3client.generatePresignedUrl(request); + System.out.println(URLify(objectURL.toString())); + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_share.xml b/app/src/main/res/layout/activity_share.xml new file mode 100644 index 0000000..168ee50 --- /dev/null +++ b/app/src/main/res/layout/activity_share.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file -- 2.39.5 From fd8693601525402b9d81a8cb56ab03844033ec82 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sun, 18 Sep 2022 11:37:31 -0700 Subject: [PATCH 005/224] share file frontend --- .idea/misc.xml | 1 + .../page/s3manager/ObjectSelect.java | 3 +- .../java/asgardius/page/s3manager/Share.java | 55 ++++++-- app/src/main/res/layout/activity_share.xml | 117 +++++++++++++++++- app/src/main/res/menu/object_menu.xml | 2 +- app/src/main/res/values-es/strings.xml | 11 +- app/src/main/res/values/strings.xml | 11 +- 7 files changed, 181 insertions(+), 19 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index a3f0bb8..8b5abe5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -14,6 +14,7 @@ + diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java index 31d3b56..f187c93 100644 --- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java @@ -7,7 +7,6 @@ import androidx.recyclerview.widget.RecyclerView; import android.content.DialogInterface; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.view.MenuItem; import android.view.View; @@ -306,7 +305,7 @@ public class ObjectSelect extends AppCompatActivity { } 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(); upload(); - } else if (menuItem.getTitle() == getResources().getString(R.string.file_external)) { + } else if (menuItem.getTitle() == getResources().getString(R.string.file_share)) { share(prefix + Name.get(position).toString()); } else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) { if (menuItem.getTitle() == getResources().getString(R.string.file_del)) { diff --git a/app/src/main/java/asgardius/page/s3manager/Share.java b/app/src/main/java/asgardius/page/s3manager/Share.java index 5a01179..44ecead 100644 --- a/app/src/main/java/asgardius/page/s3manager/Share.java +++ b/app/src/main/java/asgardius/page/s3manager/Share.java @@ -2,7 +2,12 @@ package asgardius.page.s3manager; import androidx.appcompat.app.AppCompatActivity; +import android.content.Intent; +import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; import android.widget.Toast; import com.amazonaws.auth.AWSCredentials; @@ -24,6 +29,9 @@ public class Share extends AppCompatActivity { AWSCredentials myCredentials; AmazonS3 s3client; Calendar mycal; + EditText datepick, monthpick, yearpick, hourpick, minutepick; + int date, month, year, hour, minute; + Button share; public static String URLify(String str) { str = str.trim(); @@ -59,6 +67,12 @@ public class Share extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_share); mycal = Calendar.getInstance(); + datepick = (EditText)findViewById(R.id.Date); + monthpick = (EditText)findViewById(R.id.Month); + yearpick = (EditText)findViewById(R.id.Year); + hourpick = (EditText)findViewById(R.id.Hour); + minutepick = (EditText)findViewById(R.id.Minute); + share = (Button)findViewById(R.id.share); endpoint = getIntent().getStringExtra("endpoint"); username = getIntent().getStringExtra("username"); password = getIntent().getStringExtra("password"); @@ -78,17 +92,36 @@ public class Share extends AppCompatActivity { s3ClientOptions.setPathStyleAccess(true); } s3client.setS3ClientOptions(s3ClientOptions); - mycal.set(Calendar.YEAR, 2022); - mycal.set(Calendar.MONTH, 8); - mycal.set(Calendar.DATE, 18); - mycal.set(Calendar.HOUR, 14); - mycal.set(Calendar.MINUTE, 15); - mycal.set(Calendar.SECOND, 28); - Date expiration = mycal.getTime(); - System.out.println(expiration); + share.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View view) { + //buttonaction + try { + date = Integer.parseInt(datepick.getText().toString()); + month = Integer.parseInt(monthpick.getText().toString()); + year = Integer.parseInt(yearpick.getText().toString()); + hour = Integer.parseInt(hourpick.getText().toString()); + minute = Integer.parseInt(minutepick.getText().toString()); + mycal.set(Calendar.YEAR, year); + mycal.set(Calendar.MONTH, month-1); + mycal.set(Calendar.DATE, date); + mycal.set(Calendar.HOUR, hour); + mycal.set(Calendar.MINUTE, minute); + mycal.set(Calendar.SECOND, 0); + Date expiration = mycal.getTime(); + System.out.println(expiration); + GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration); + URL objectURL = s3client.generatePresignedUrl(request); + System.out.println(URLify(objectURL.toString())); + Intent shareIntent = new Intent(Intent.ACTION_SEND); + shareIntent.setType("text/plain"); + shareIntent.putExtra(Intent.EXTRA_TEXT, URLify(objectURL.toString())); + startActivity(Intent.createChooser(shareIntent, "choose one")); + } catch (Exception e) { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.invalid_expiration_date), Toast.LENGTH_SHORT).show(); + } + } - GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration); - URL objectURL = s3client.generatePresignedUrl(request); - System.out.println(URLify(objectURL.toString())); + }); } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_share.xml b/app/src/main/res/layout/activity_share.xml index 168ee50..27942ff 100644 --- a/app/src/main/res/layout/activity_share.xml +++ b/app/src/main/res/layout/activity_share.xml @@ -1,9 +1,120 @@ - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + +