Browse Source

Fix file not being sent

Yohan Simard 3 years ago
parent
commit
5f0d2ea7b1
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      src/main/java/fr/insa/clavardator/chat/FileMessage.java

+ 5
- 2
src/main/java/fr/insa/clavardator/chat/FileMessage.java View File

@@ -15,6 +15,7 @@ public class FileMessage extends Message {
15 15
 
16 16
 	private final String fileName;
17 17
 	private String path;
18
+	byte[] rawFile = null;
18 19
 
19 20
 	/**
20 21
 	 * Constructs a FileMessage
@@ -84,8 +85,10 @@ public class FileMessage extends Message {
84 85
 		}
85 86
 
86 87
 		// write to the file
87
-		FileInputStream stream = new FileInputStream(fileName);
88
-		byte[] rawFile = stream.readAllBytes();
88
+		if (rawFile == null) {
89
+			FileInputStream stream = new FileInputStream(fileName);
90
+			rawFile = stream.readAllBytes();
91
+		}
89 92
 
90 93
 		FileOutputStream ostream = new FileOutputStream(file);
91 94
 		ostream.write(rawFile);

Loading…
Cancel
Save