get file link
This commit is contained in:
parent
05f54a3d8a
commit
c532ddaa1a
6 changed files with 31 additions and 74 deletions
17
.idea/deploymentTargetDropDown.xml
Normal file
17
.idea/deploymentTargetDropDown.xml
Normal 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>
|
|
@ -15,9 +15,6 @@
|
|||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AsgardiusS3Manager"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".FileShare"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".TextViewer"
|
||||
android:exported="false" />
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -229,7 +229,9 @@ 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.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;
|
||||
}
|
||||
|
@ -280,15 +282,16 @@ public class ObjectSelect extends AppCompatActivity {
|
|||
|
||||
private void share(String object) {
|
||||
|
||||
Toast.makeText(ObjectSelect.this, "This feature is not yet implemented", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(this, FileShare.class);
|
||||
intent.putExtra("endpoint", endpoint);
|
||||
intent.putExtra("username", username);
|
||||
intent.putExtra("password", password);
|
||||
intent.putExtra("bucket", bucket);
|
||||
intent.putExtra("prefix", prefix + object);
|
||||
//intent.putExtra("treelevel", treelevel+1);
|
||||
startActivity(intent);
|
||||
try {
|
||||
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Share Link");
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, object);
|
||||
startActivity(Intent.createChooser(shareIntent, "choose one"));
|
||||
} catch(Exception e) {
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -3,7 +3,7 @@
|
|||
<string name="aws_endpoint">.amazonaws.com</string>
|
||||
<string name="title_activity_video_player">VideoPlayer</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="accountadd_button">Add Account</string>
|
||||
<string name="accounttest_button">Test credentials</string>
|
||||
|
|
Loading…
Reference in a new issue