|
14 | 14 | import io.facturapi.models.OrganizationUserAccess; |
15 | 15 | import io.facturapi.models.SearchResult; |
16 | 16 | import io.facturapi.models.Series; |
| 17 | +import java.io.File; |
17 | 18 | import java.io.IOException; |
18 | 19 | import java.nio.file.Files; |
19 | | -import java.nio.file.Path; |
20 | 20 | import java.util.List; |
21 | 21 | import java.util.Map; |
22 | 22 |
|
@@ -89,21 +89,48 @@ public DomainAvailability checkDomainAvailability(Map<String, ?> query) { |
89 | 89 | /** |
90 | 90 | * Uploads organization logo file. |
91 | 91 | */ |
92 | | - public Organization uploadLogo(String id, Path filePath) throws IOException { |
93 | | - byte[] fileBytes = Files.readAllBytes(filePath); |
| 92 | + public Organization uploadLogo(String id, File file) throws IOException { |
| 93 | + return uploadLogo(id, Files.readAllBytes(file.toPath()), file.getName()); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Uploads organization logo file bytes. |
| 98 | + */ |
| 99 | + public Organization uploadLogo(String id, byte[] fileBytes, String fileName) { |
94 | 100 | MultipartBody multipartBody = new MultipartBodyBuilder() |
95 | | - .addFile("file", filePath.getFileName().toString(), fileBytes, "application/octet-stream") |
| 101 | + .addFile("file", fileName, fileBytes, "application/octet-stream") |
96 | 102 | .build(); |
97 | 103 | return client.putMultipart("/organizations/" + id + "/logo", multipartBody, Organization.class); |
98 | 104 | } |
99 | 105 |
|
100 | 106 | /** |
101 | 107 | * Uploads organization CSD certificate files. |
102 | 108 | */ |
103 | | - public Organization uploadCertificate(String id, Path cerFile, Path keyFile, String password) throws IOException { |
| 109 | + public Organization uploadCertificate(String id, File cerFile, File keyFile, String password) throws IOException { |
| 110 | + return uploadCertificate( |
| 111 | + id, |
| 112 | + Files.readAllBytes(cerFile.toPath()), |
| 113 | + cerFile.getName(), |
| 114 | + Files.readAllBytes(keyFile.toPath()), |
| 115 | + keyFile.getName(), |
| 116 | + password |
| 117 | + ); |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * Uploads organization CSD certificate file bytes. |
| 122 | + */ |
| 123 | + public Organization uploadCertificate( |
| 124 | + String id, |
| 125 | + byte[] cerFileBytes, |
| 126 | + String cerFileName, |
| 127 | + byte[] keyFileBytes, |
| 128 | + String keyFileName, |
| 129 | + String password |
| 130 | + ) { |
104 | 131 | MultipartBody multipartBody = new MultipartBodyBuilder() |
105 | | - .addFile("cer", cerFile.getFileName().toString(), Files.readAllBytes(cerFile), "application/octet-stream") |
106 | | - .addFile("key", keyFile.getFileName().toString(), Files.readAllBytes(keyFile), "application/octet-stream") |
| 132 | + .addFile("cer", cerFileName, cerFileBytes, "application/octet-stream") |
| 133 | + .addFile("key", keyFileName, keyFileBytes, "application/octet-stream") |
107 | 134 | .addField("password", password) |
108 | 135 | .build(); |
109 | 136 | return client.putMultipart("/organizations/" + id + "/certificate", multipartBody, Organization.class); |
|
0 commit comments