| | |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | |
| | | import com.obs.services.ObsClient; |
| | | import com.obs.services.model.HttpMethodEnum; |
| | | import com.obs.services.model.TemporarySignatureRequest; |
| | | import com.obs.services.model.TemporarySignatureResponse; |
| | | import com.qxueyou.scc.config.HweiOBSConfig; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | |
| | | @Autowired |
| | | private ApplicationContext appContext; |
| | | |
| | | @Autowired |
| | | private HweiOBSConfig hweiOBSConfig; |
| | | |
| | | @Autowired |
| | | private IClassLectureService classLectureService; |
| | |
| | | // CollectionUtils.newObjectMap("path", path, "name", res.getName(), "coverPageUrl", res.getCoverPageUrl(), "size", |
| | | // this.classLectureService.readDocPageCount(res.getItemDestId())));//文件的页数 |
| | | // }else { |
| | | // URL有效期,3600秒 |
| | | long expireSeconds = 3600L; |
| | | TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.GET, expireSeconds); |
| | | //设置桶名,一般都是写在配置里,这里直接赋值即可 |
| | | request.setBucketName(hweiOBSConfig.getBucketName()); |
| | | //这里相当于设置你上传到obs的文件路 |
| | | request.setObjectKey((String) path); |
| | | |
| | | ObsClient obsClient = new ObsClient(hweiOBSConfig.getAccessKey(),hweiOBSConfig.getSecurityKey(),hweiOBSConfig.getEndPoint()); |
| | | TemporarySignatureResponse temporarySignatureResponse=obsClient.createTemporarySignature(request); |
| | | return new Result(true, "success", |
| | | CollectionUtils.newObjectMap("path", path, "name", res.getName(), "coverPageUrl", res.getCoverPageUrl(), "size", 0)); |
| | | CollectionUtils.newObjectMap("path", temporarySignatureResponse.getSignedUrl(), "name", res.getName(), "coverPageUrl", res.getCoverPageUrl(), "size", 0)); |
| | | // } |
| | | |
| | | } |