|
@@ -8,6 +8,11 @@ import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.net.MalformedURLException;
|
|
|
|
|
+import java.net.URL;
|
|
|
|
|
+import java.net.URLConnection;
|
|
|
|
|
+
|
|
|
@Service
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class AttachmentService {
|
|
public class AttachmentService {
|
|
@@ -17,4 +22,20 @@ public class AttachmentService {
|
|
|
public Page<Attachment> all(PageQuery pageQuery) {
|
|
public Page<Attachment> all(PageQuery pageQuery) {
|
|
|
return attachmentRepo.findAll(JpaUtils.toSpecification(pageQuery, Attachment.class), JpaUtils.toPageRequest(pageQuery));
|
|
return attachmentRepo.findAll(JpaUtils.toSpecification(pageQuery, Attachment.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ KB
|
|
|
|
|
+ */
|
|
|
|
|
+ public int getSize(String oss) {
|
|
|
|
|
+ int size = 0;
|
|
|
|
|
+ try {
|
|
|
|
|
+ URL url = new URL(oss);
|
|
|
|
|
+ URLConnection conn = url.openConnection();
|
|
|
|
|
+ size = conn.getContentLength();
|
|
|
|
|
+ conn.getInputStream().close();
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return size/1024;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|