Prevent re-downloading file if it's locally available on the server.

This commit is contained in:
Joshua Sigona 2020-07-21 05:18:08 +09:00
parent cd83f7270c
commit f276a783c1
16 changed files with 9 additions and 3 deletions

BIN
files/Blackjack.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
files/img.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

BIN
files/img0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

BIN
files/img1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
files/img10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

BIN
files/img2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
files/img3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
files/img4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
files/img5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
files/img6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
files/img7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
files/img8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

BIN
files/img9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
files/plays/test Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -134,9 +134,15 @@ public class Controller {
//System.out.println(body); //System.out.println(body);
try { try {
System.out.println(url); System.out.println(url);
downloadFileFromUrl(url,"temp"); BufferedImage img = null;
//BufferedImage img = ImageUtils.toBufferedImage(ImageIO.read(new File("temp")).getScaledInstance(1227, 690, Image.SCALE_SMOOTH)); if (url.contains("http://projectdivar.com/files/")) {
BufferedImage img = ImageIO.read(new File("temp")); //System.out.println("Locally available.");
img = ImageIO.read(new File("files",url.replace("http://projectdivar.com/files/", "")));
} else {
downloadFileFromUrl(url,"temp");
//BufferedImage img = ImageUtils.toBufferedImage(ImageIO.read(new File("temp")).getScaledInstance(1227, 690, Image.SCALE_SMOOTH));
img = ImageIO.read(new File("temp"));
}
if (img.getWidth()!=1200) { if (img.getWidth()!=1200) {
//Resize. //Resize.
img = ImageUtils.toBufferedImage(ImageIO.read(new File("temp")).getScaledInstance(1200, 675, Image.SCALE_SMOOTH)); img = ImageUtils.toBufferedImage(ImageIO.read(new File("temp")).getScaledInstance(1200, 675, Image.SCALE_SMOOTH));