Skip to content

Commit 8fec495

Browse files
author
TechsCode
committed
Fixed Url Encoding issue
1 parent 1456f71 commit 8fec495

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/me/TechsCode/ReleaseServer/WebRequestsHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import org.springframework.web.bind.annotation.*;
99

1010
import java.io.File;
11+
import java.io.UnsupportedEncodingException;
1112
import java.net.MalformedURLException;
13+
import java.net.URLEncoder;
1214
import java.util.List;
1315
import java.util.Optional;
1416
import java.util.stream.Collectors;
@@ -56,9 +58,9 @@ public Object download(@RequestParam(value = "token", required = false) String t
5658

5759
return ResponseEntity.ok()
5860
.contentType(MediaType.APPLICATION_OCTET_STREAM)
59-
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + asset.getName() + "\"")
61+
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(asset.getName(), "UTF-8") + "\"")
6062
.body(new UrlResource(asset.getPath()));
61-
} catch (MalformedURLException e) {
63+
} catch (MalformedURLException | UnsupportedEncodingException e) {
6264
e.printStackTrace();
6365
return "Error: "+e.getMessage();
6466
}

0 commit comments

Comments
 (0)