get file link

This commit is contained in:
Page Asgardius 2022-09-07 19:25:17 -07:00
parent 05f54a3d8a
commit c532ddaa1a
6 changed files with 31 additions and 74 deletions

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/4.7_WXGA_API_31.avd" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-09-08T02:24:30.038432Z" />
</component>
</project>

View file

@ -15,9 +15,6 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.AsgardiusS3Manager" android:theme="@style/Theme.AsgardiusS3Manager"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".FileShare"
android:exported="false" />
<activity <activity
android:name=".TextViewer" android:name=".TextViewer"
android:exported="false" /> android:exported="false" />

View file

@ -1,38 +0,0 @@
package asgardius.page.s3manager;
import static com.amazonaws.regions.Regions.US_EAST_1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
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;
public class FileShare extends AppCompatActivity {
String username, password, endpoint, bucket, prefix;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_share);
endpoint = getIntent().getStringExtra("endpoint");
username = getIntent().getStringExtra("username");
password = getIntent().getStringExtra("password");
bucket = getIntent().getStringExtra("bucket");
prefix = getIntent().getStringExtra("prefix");
Region region = Region.getRegion(US_EAST_1);
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
if (!endpoint.contains(getResources().getString(R.string.aws_endpoint))) {
s3ClientOptions.setPathStyleAccess(true);
}
AWSCredentials myCredentials = new BasicAWSCredentials(username, password);
AmazonS3 s3client = new AmazonS3Client(myCredentials, region);
s3client.setEndpoint(endpoint);
s3client.setS3ClientOptions(s3ClientOptions);
}
}

View file

@ -229,7 +229,9 @@ public class ObjectSelect extends AppCompatActivity {
// Toast message on menu item clicked // Toast message on menu item clicked
//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.file_share)) { if (menuItem.getTitle() == getResources().getString(R.string.file_share)) {
share(Name.get(position).toString()); GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
URL objectURL = s3client.generatePresignedUrl(request);
share(objectURL.toString());
} }
return true; return true;
} }
@ -280,15 +282,16 @@ public class ObjectSelect extends AppCompatActivity {
private void share(String object) { private void share(String object) {
Toast.makeText(ObjectSelect.this, "This feature is not yet implemented", Toast.LENGTH_SHORT).show(); try {
Intent intent = new Intent(this, FileShare.class);
intent.putExtra("endpoint", endpoint); Intent shareIntent = new Intent(Intent.ACTION_SEND);
intent.putExtra("username", username); shareIntent.setType("text/plain");
intent.putExtra("password", password); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Share Link");
intent.putExtra("bucket", bucket); shareIntent.putExtra(Intent.EXTRA_TEXT, object);
intent.putExtra("prefix", prefix + object); startActivity(Intent.createChooser(shareIntent, "choose one"));
//intent.putExtra("treelevel", treelevel+1); } catch(Exception e) {
startActivity(intent); Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
}
} }
} }

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FileShare">
<EditText
android:id="@+id/textShow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ems="10"
android:focusable="false"
android:gravity="start|top"
android:inputType="textMultiLine"
android:text="Testting\nEditor"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="79dp"
tools:layout_editor_absoluteY="25dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -3,7 +3,7 @@
<string name="aws_endpoint">.amazonaws.com</string> <string name="aws_endpoint">.amazonaws.com</string>
<string name="title_activity_video_player">VideoPlayer</string> <string name="title_activity_video_player">VideoPlayer</string>
<string name="broken_database">Local database is corrupted. Please reinstall this app</string> <string name="broken_database">Local database is corrupted. Please reinstall this app</string>
<string name="file_share">Share file</string> <string name="file_share">Get object link</string>
<string name="accountselect">Please choose an account</string> <string name="accountselect">Please choose an account</string>
<string name="accountadd_button">Add Account</string> <string name="accountadd_button">Add Account</string>
<string name="accounttest_button">Test credentials</string> <string name="accounttest_button">Test credentials</string>