add FTP address check before upload

This commit is contained in:
2024-12-17 09:44:09 +07:00
parent d7719ae312
commit 4465862564
4 changed files with 27 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
#Tue Dec 17 09:22:55 WIB 2024 #Tue Dec 17 09:43:51 WIB 2024
AudioPhase1=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase1.mp3 AudioPhase1=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase1.mp3
AudioPhase2=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase2.mp3 AudioPhase2=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase2.mp3
AudioPhase3=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase3.mp3 AudioPhase3=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase3.mp3

Binary file not shown.

View File

@@ -1,7 +1,8 @@
package FTP; package FTP;
import lombok.val;
import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.io.CopyStreamEvent;
import org.apache.commons.net.io.CopyStreamListener;
import java.io.*; import java.io.*;
@@ -73,9 +74,19 @@ public class FTPUpload {
File localFile = new File(file); File localFile = new File(file);
if (localFile.exists()) { if (localFile.exists()) {
FileInputStream input = new FileInputStream(localFile); FileInputStream input = new FileInputStream(localFile);
ProgressInputStream pis = new ProgressInputStream(file, input, localFile.length(), event); //ProgressInputStream pis = new ProgressInputStream(file, input, localFile.length(), event);
if (event!=null) event.onUploadStarted(file); if (event!=null) event.onUploadStarted(file);
ftp.storeFile(localFile.getName(), pis); ftp.setCopyStreamListener(new CopyStreamListener() {
@Override
public void bytesTransferred(CopyStreamEvent copyStreamEvent) {
}
@Override
public void bytesTransferred(long totalBytesTransferred, int bytesTransferred, long streamSize) {
if (event!=null) event.onUploadProgress(file, totalBytesTransferred, streamSize);
}
});
ftp.storeFile(localFile.getName(), input);
input.close(); input.close();
if (event!=null) event.onUploadSuccess(file); if (event!=null) event.onUploadSuccess(file);
success++; success++;

View File

@@ -5,7 +5,7 @@
<?import javafx.scene.image.*?> <?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane prefHeight="280.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="id.co.gtc.erhacam.Cameradetail"> <AnchorPane prefHeight="280.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="id.co.gtc.erhacam.Cameradetail">
<children> <children>
<GridPane layoutX="5.0" layoutY="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <GridPane layoutX="5.0" layoutY="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints> <columnConstraints>
@@ -45,8 +45,8 @@
<children> <children>
<GridPane layoutX="-28.0" layoutY="-29.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <GridPane layoutX="-28.0" layoutY="-29.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="70.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints fillWidth="false" maxWidth="-Infinity" minWidth="-Infinity" percentWidth="10.0" prefWidth="100.0" /> <ColumnConstraints fillWidth="false" minWidth="10.0" percentWidth="20.0" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
@@ -103,12 +103,15 @@
</AnchorPane> </AnchorPane>
<AnchorPane fx:id="streamanchor"> <AnchorPane fx:id="streamanchor">
<children> <children>
<HBox alignment="CENTER" prefHeight="240.0" prefWidth="700.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> <StackPane prefHeight="240.0" prefWidth="351.2" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<ImageView fx:id="camerastream" fitHeight="240.0" pickOnBounds="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <children>
<image> <ImageView fx:id="camerastream" fitHeight="240.0" pickOnBounds="true">
<Image url="@gtcbackground.png" /> <image>
</image> <Image url="@gtcbackground.png" />
</ImageView> </image>
</ImageView>
</children>
</StackPane>
</children> </children>
</AnchorPane> </AnchorPane>
</children> </children>