Skip to content

Commit

Permalink
rolling back FromStringToFile
Browse files Browse the repository at this point in the history
  • Loading branch information
LuciaM1 committed Sep 20, 2024
1 parent 652f75b commit e6e03da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public static String toHexString(byte[] hash) {
public static File fromStringToFile(String fileBase64) {
try {
byte[] decodedBytes = Base64.getDecoder().decode(fileBase64);
Files.createDirectories(Path.of("/decoded"));
File tempFile = File.createTempFile("tempfile", ".tmp", new File("/decoded"));
File tempFile = File.createTempFile("tempfile", ".tmp");
try (FileOutputStream fos = new FileOutputStream(tempFile)) {
fos.write(decodedBytes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
@QuarkusTest
class FileUtilitiesTest {

// @Test
// void testFromStringToFile_ValidBase64() throws IOException {
// String validBase64 = Base64.getEncoder().encodeToString("Hello World!".getBytes());
// String fileName = "filename";
//
// File result = fromStringToFile(validBase64);
//
// assertNotNull(result);
// assertTrue(result.exists());
//
// byte[] fileContent = Files.readAllBytes(result.toPath());
// assertEquals("Hello World!", new String(fileContent));
//
// }
@Test
void testFromStringToFile_ValidBase64() throws IOException {
String validBase64 = Base64.getEncoder().encodeToString("Hello World!".getBytes());
String fileName = "filename";

File result = fromStringToFile(validBase64);

assertNotNull(result);
assertTrue(result.exists());

byte[] fileContent = Files.readAllBytes(result.toPath());
assertEquals("Hello World!", new String(fileContent));

}

@Test
void testFromStringToFile_InvalidBase64() {
Expand Down

0 comments on commit e6e03da

Please sign in to comment.