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.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
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)) {
|
||||
//load media file
|
||||
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);
|
||||
videoPlayer(objectURL.toString());
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -33,6 +33,8 @@ public class Share extends AppCompatActivity {
|
|||
EditText datepick, monthpick, yearpick, hourpick, minutepick;
|
||||
int date, month, year, hour, minute;
|
||||
Button share, external;
|
||||
GeneratePresignedUrlRequest request;
|
||||
Date expiration;
|
||||
|
||||
public static String URLify(String str) {
|
||||
str = str.trim();
|
||||
|
@ -116,9 +118,9 @@ public class Share extends AppCompatActivity {
|
|||
mycal.set(Calendar.HOUR, hour);
|
||||
mycal.set(Calendar.MINUTE, minute);
|
||||
mycal.set(Calendar.SECOND, 0);
|
||||
Date expiration = mycal.getTime();
|
||||
expiration = mycal.getTime();
|
||||
//System.out.println(expiration);
|
||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration);
|
||||
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);
|
||||
|
@ -137,7 +139,17 @@ public class Share extends AppCompatActivity {
|
|||
public void onClick(View view) {
|
||||
//buttonaction
|
||||
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);
|
||||
//System.out.println(URLify(objectURL.toString()));
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
|
|
Loading…
Reference in a new issue