Browse Source

Minor refactoring

pull/9542/head
ViacheslavKlimov 3 years ago
parent
commit
2b9eab0150
  1. 4
      application/src/main/java/org/thingsboard/server/controller/ImageController.java
  2. 2
      application/src/main/java/org/thingsboard/server/service/install/update/SystemImagesMigrator.java

4
application/src/main/java/org/thingsboard/server/controller/ImageController.java

@ -139,7 +139,7 @@ public class ImageController extends BaseController {
return downloadIfChanged(etag, imageInfo, descriptor.getPreviewDescriptor(), () -> imageService.getImagePreview(tenantId, imageInfo.getId())); return downloadIfChanged(etag, imageInfo, descriptor.getPreviewDescriptor(), () -> imageService.getImagePreview(tenantId, imageInfo.getId()));
} }
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@GetMapping(IMAGE_URL + "/info") @GetMapping(IMAGE_URL + "/info")
public TbResourceInfo getImageInfo(@PathVariable String type, public TbResourceInfo getImageInfo(@PathVariable String type,
@PathVariable String key) throws ThingsboardException { @PathVariable String key) throws ThingsboardException {
@ -147,7 +147,7 @@ public class ImageController extends BaseController {
} }
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@GetMapping("/images") @GetMapping("/api/images")
public PageData<TbResourceInfo> getImages(@ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) public PageData<TbResourceInfo> getImages(@ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
@RequestParam int pageSize, @RequestParam int pageSize,
@ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)

2
application/src/main/java/org/thingsboard/server/service/install/update/SystemImagesMigrator.java

@ -189,7 +189,7 @@ public class SystemImagesMigrator { // TEMPORARY
return data; return data;
} }
String imageMediaType = StringUtils.substringBetween(data, "data:", ";base64"); String imageMediaType = StringUtils.substringBetween(data, "data:", ";base64");
String extension = MediaTypeUtils.mediaTypeToFileExtension(imageMediaType); String extension = ImageUtils.mediaTypeToFileExtension(imageMediaType);
imageKey += "." + extension; imageKey += "." + extension;
byte[] image = Base64.getDecoder().decode(base64Data); byte[] image = Base64.getDecoder().decode(base64Data);

Loading…
Cancel
Save