package com.bonus.core.common.utils;

import com.amazonaws.services.s3.AmazonS3;
import org.springframework.beans.factory.InitializingBean;

import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class OssTemplate implements InitializingBean {
   private final OssProperties ossProperties;
   private AmazonS3 amazonS3;


   public String getObjectURL(String bucketName, String objectName, Integer expires) {
      try {
         Date date = new Date();
         Calendar calendar = new GregorianCalendar();
         calendar.setTime(date);
         calendar.add(13, expires);
         URL url = this.amazonS3.generatePresignedUrl(bucketName, objectName, calendar.getTime());
         return url.toString();
      } catch (Throwable var7) {
         throw var7;
      }
    }
   public OssTemplate(final OssProperties ossProperties) {
      this.ossProperties = ossProperties;
   }

   @Override
   public void afterPropertiesSet() throws Exception {

   }
}
