Skip to content

Commit 924c597

Browse files
Small changes
1 parent 5dc19f2 commit 924c597

File tree

11 files changed

+266
-226
lines changed

11 files changed

+266
-226
lines changed

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,8 @@ hs_err_pid*
5555
# Sensitive or high-churn files
5656
.idea/**/dataSources/
5757
.idea/**/dataSources.ids
58-
.idea/**/dataSources.local.xml
59-
.idea/**/sqlDataSources.xml
60-
.idea/**/dynamic.xml
61-
.idea/**/uiDesigner.xml
62-
.idea/**/dbnavigator.xml
58+
.idea/**/*.xml
59+
.idea/**/*.iml
6360

6461
# Gradle
6562
.idea/**/gradle.xml

file-storage/src/main/java/com/maestro/examples/app/azure/filestorage/FileStorageApplication.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
@SpringBootApplication
77
public class FileStorageApplication {
8-
98
public static void main(String[] args) {
109
SpringApplication.run(FileStorageApplication.class, args);
1110
}
12-
1311
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.maestro.examples.app.azure.filestorage.controllers;
2+
3+
import com.maestro.examples.app.azure.filestorage.domains.DataBlock;
4+
import com.maestro.examples.app.azure.filestorage.domains.FilePrm;
5+
import com.maestro.examples.app.azure.filestorage.services.AzureBlobStorageService;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.validation.annotation.Validated;
8+
import org.springframework.web.bind.annotation.*;
9+
10+
@RestController
11+
@RequestMapping("/bs")
12+
@Slf4j
13+
public class AzureBlobStorageController {
14+
private AzureBlobStorageService fileService;
15+
16+
public AzureBlobStorageController(AzureBlobStorageService fileService) {
17+
this.fileService = fileService;
18+
}
19+
20+
/**
21+
* Creating container in Azure Blob Storage before uploading document file
22+
*
23+
* @param idContainer document id
24+
* @return String
25+
*/
26+
@PostMapping(value = "/{idContainer}/files/before-upload")
27+
public String beforeUploadDocFile(@PathVariable String idContainer) {
28+
return fileService.beforeUpload(idContainer);
29+
}
30+
31+
/**
32+
* Uploading document file chunk into Azure Blob Storage
33+
*
34+
* @param idContainer document id
35+
* @param idFile file id
36+
*/
37+
@PutMapping(value = "{idContainer}/files/{idFile}")
38+
public void uploadDocFile(@PathVariable String idContainer, @PathVariable String idFile, @RequestBody @Validated DataBlock data) {
39+
fileService.uploadFile(idContainer, idFile, data);
40+
}
41+
42+
/**
43+
* Completing uploading file;s chunk into Azure Blob Storage
44+
*
45+
* @param idContainer document id
46+
* @param idFile file id
47+
*/
48+
@PostMapping(value = "/{idContainer}/files/{idFile}")
49+
public void completeUploadDocFile(@PathVariable String idContainer, @PathVariable String idFile, @RequestBody @Validated FilePrm data) {
50+
fileService.completeUploadFile(idContainer, idFile, data);
51+
}
52+
53+
/**
54+
* Deleting file from Azure Blob Storage
55+
*
56+
* @param idContainer document id
57+
* @param idFile file id
58+
*/
59+
@DeleteMapping(value = "{idContainer}/files/{idFile}")
60+
public void deleteDocFile(@PathVariable String idContainer, @PathVariable String idFile) {
61+
fileService.deleteFile(idContainer, idFile);
62+
}
63+
64+
/**
65+
* Getting document file link from Azure Blob Storage
66+
*
67+
* @param idContainer document id
68+
* @param idFile file id
69+
*/
70+
@GetMapping(value = "/{idContainer}/files/{idFile}/link")
71+
public String getLinkDocFile(@PathVariable String idContainer, @PathVariable String idFile) {
72+
return fileService.getLinkFile(idContainer, idFile);
73+
}
74+
}

file-storage/src/main/java/com/maestro/examples/app/azure/filestorage/controllers/FilesPublicController.java

Lines changed: 0 additions & 176 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import org.springframework.web.bind.annotation.RestController;
55

66
@RestController
7-
public class HelloController {
8-
@GetMapping(value = "/welcome")
7+
public class WelcomeController {
8+
@GetMapping(value = "/")
99
public String welcome () {
10-
return "Welcome to Spring Boot";
10+
return "Welcome from Spring Boot app";
1111
}
1212
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
package com.maestro.examples.app.azure.filestorage.records;
1+
package com.maestro.examples.app.azure.filestorage.domains;
22

3+
import lombok.Builder;
34
import lombok.Data;
5+
import lombok.NoArgsConstructor;
46

57
/**
68
* Information about uploaded file chunk
79
*/
810
@Data
11+
@Builder
912
public class DataBlock {
1013
/**
1114
* Base64 block id to upload
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package com.maestro.examples.app.azure.filestorage.records;
1+
package com.maestro.examples.app.azure.filestorage.domains;
22

3+
import lombok.Builder;
34
import lombok.Data;
45

56
import java.util.List;
@@ -8,6 +9,7 @@
89
* Dto class with information about file to complete upload to the storage
910
*/
1011
@Data
12+
@Builder
1113
public class FilePrm {
1214
/**
1315
* The file name

0 commit comments

Comments
 (0)