fix expiration time on videos
This commit is contained in:
parent
84591d4f6f
commit
a546960cbe
2 changed files with 25 additions and 4 deletions
|
@ -30,6 +30,8 @@ import com.amazonaws.services.s3.model.S3ObjectSummary;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -277,7 +279,14 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
} else if (Img.get(position).equals(R.drawable.audiofile) || Img.get(position).equals(R.drawable.videofile)) {
|
} else if (Img.get(position).equals(R.drawable.audiofile) || Img.get(position).equals(R.drawable.videofile)) {
|
||||||
//load media file
|
//load media file
|
||||||
try {
|
try {
|
||||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
|
Date expiration = new Date();
|
||||||
|
Calendar mycal = Calendar.getInstance();
|
||||||
|
mycal.setTime(expiration);
|
||||||
|
//System.out.println("today is " + mycal.getTime());
|
||||||
|
mycal.add(Calendar.HOUR, 6);
|
||||||
|
//System.out.println("Expiration date: " + mycal.getTime());
|
||||||
|
expiration = mycal.getTime();
|
||||||
|
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString()).withExpiration(expiration);;
|
||||||
URL objectURL = s3client.generatePresignedUrl(request);
|
URL objectURL = s3client.generatePresignedUrl(request);
|
||||||
videoPlayer(objectURL.toString());
|
videoPlayer(objectURL.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -33,6 +33,8 @@ public class Share extends AppCompatActivity {
|
||||||
EditText datepick, monthpick, yearpick, hourpick, minutepick;
|
EditText datepick, monthpick, yearpick, hourpick, minutepick;
|
||||||
int date, month, year, hour, minute;
|
int date, month, year, hour, minute;
|
||||||
Button share, external;
|
Button share, external;
|
||||||
|
GeneratePresignedUrlRequest request;
|
||||||
|
Date expiration;
|
||||||
|
|
||||||
public static String URLify(String str) {
|
public static String URLify(String str) {
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
|
@ -116,9 +118,9 @@ public class Share extends AppCompatActivity {
|
||||||
mycal.set(Calendar.HOUR, hour);
|
mycal.set(Calendar.HOUR, hour);
|
||||||
mycal.set(Calendar.MINUTE, minute);
|
mycal.set(Calendar.MINUTE, minute);
|
||||||
mycal.set(Calendar.SECOND, 0);
|
mycal.set(Calendar.SECOND, 0);
|
||||||
Date expiration = mycal.getTime();
|
expiration = mycal.getTime();
|
||||||
//System.out.println(expiration);
|
//System.out.println(expiration);
|
||||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration);
|
request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration);
|
||||||
URL objectURL = s3client.generatePresignedUrl(request);
|
URL objectURL = s3client.generatePresignedUrl(request);
|
||||||
//System.out.println(URLify(objectURL.toString()));
|
//System.out.println(URLify(objectURL.toString()));
|
||||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
|
@ -137,7 +139,17 @@ public class Share extends AppCompatActivity {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
//buttonaction
|
//buttonaction
|
||||||
try {
|
try {
|
||||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, object);
|
if (mediafile) {
|
||||||
|
expiration = new Date();
|
||||||
|
mycal.setTime(expiration);
|
||||||
|
//System.out.println("today is " + mycal.getTime());
|
||||||
|
mycal.add(Calendar.HOUR, 6);
|
||||||
|
//System.out.println("Expiration date: " + mycal.getTime());
|
||||||
|
expiration = mycal.getTime();
|
||||||
|
request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration);
|
||||||
|
} else {
|
||||||
|
request = new GeneratePresignedUrlRequest(bucket, object);
|
||||||
|
}
|
||||||
URL objectURL = s3client.generatePresignedUrl(request);
|
URL objectURL = s3client.generatePresignedUrl(request);
|
||||||
//System.out.println(URLify(objectURL.toString()));
|
//System.out.println(URLify(objectURL.toString()));
|
||||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
|
|
Loading…
Reference in a new issue