summaryrefslogtreecommitdiffstats
path: root/Dozentenmodul/src/ftp/UploadTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'Dozentenmodul/src/ftp/UploadTask.java')
-rw-r--r--Dozentenmodul/src/ftp/UploadTask.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/Dozentenmodul/src/ftp/UploadTask.java b/Dozentenmodul/src/ftp/UploadTask.java
index 788acad6..06d76dc8 100644
--- a/Dozentenmodul/src/ftp/UploadTask.java
+++ b/Dozentenmodul/src/ftp/UploadTask.java
@@ -5,6 +5,8 @@ import java.io.FileInputStream;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
+
+import models.Image;
/**
* Executes the file upload in a background thread and updates progress to
@@ -47,14 +49,16 @@ public class UploadTask extends SwingWorker<Void, Void> {
FileInputStream inputStream = new FileInputStream(uploadFile);
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead = -1;
+ int i=0;
long totalBytesRead = 0;
int percentCompleted = 0;
long fileSize = uploadFile.length();
+ Image.image.setFilesize(fileSize);
long start=System.nanoTime();
final double NANOS_PER_SECOND = 1000000000.0;
final double BYTES_PER_MIB = 1024*1024;
while ((bytesRead = inputStream.read(buffer)) != -1 && isCancelled()==false) {
- util.writeFileBytes(buffer, 0, bytesRead);
+ util.writeFileBytes(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
percentCompleted = (int) (totalBytesRead * 100 / fileSize);
double speed = NANOS_PER_SECOND / BYTES_PER_MIB * totalBytesRead / (System.nanoTime() - start + 1);