upload image and text from Android to Spring boot
up vote
-1
down vote
favorite
i got question. Do you have any tips how to implement Post request to upload image with data to spring boot api ?. Here i have code from Spring.
@PostMapping("/api/attachment/add")
public void addAttachmentApi(@RequestParam("file") MultipartFile file,
@RequestParam String orderId,
@RequestParam String title,
@RequestParam String description)
{
String filePath = storageService.store(file);
Optional<Order> temporaryOrder = orderRepository.findById(orderId);
if(temporaryOrder.isPresent())
{
Order order = temporaryOrder.get();
List<Attachment> attachments = order.getAttachments();
attachments.add(new Attachment(title, description, filePath));
order.setAttachments(attachments);
orderRepository.save(order);
}
}
Thank you in advance.
add a comment |
up vote
-1
down vote
favorite
i got question. Do you have any tips how to implement Post request to upload image with data to spring boot api ?. Here i have code from Spring.
@PostMapping("/api/attachment/add")
public void addAttachmentApi(@RequestParam("file") MultipartFile file,
@RequestParam String orderId,
@RequestParam String title,
@RequestParam String description)
{
String filePath = storageService.store(file);
Optional<Order> temporaryOrder = orderRepository.findById(orderId);
if(temporaryOrder.isPresent())
{
Order order = temporaryOrder.get();
List<Attachment> attachments = order.getAttachments();
attachments.add(new Attachment(title, description, filePath));
order.setAttachments(attachments);
orderRepository.save(order);
}
}
Thank you in advance.
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
i got question. Do you have any tips how to implement Post request to upload image with data to spring boot api ?. Here i have code from Spring.
@PostMapping("/api/attachment/add")
public void addAttachmentApi(@RequestParam("file") MultipartFile file,
@RequestParam String orderId,
@RequestParam String title,
@RequestParam String description)
{
String filePath = storageService.store(file);
Optional<Order> temporaryOrder = orderRepository.findById(orderId);
if(temporaryOrder.isPresent())
{
Order order = temporaryOrder.get();
List<Attachment> attachments = order.getAttachments();
attachments.add(new Attachment(title, description, filePath));
order.setAttachments(attachments);
orderRepository.save(order);
}
}
Thank you in advance.
i got question. Do you have any tips how to implement Post request to upload image with data to spring boot api ?. Here i have code from Spring.
@PostMapping("/api/attachment/add")
public void addAttachmentApi(@RequestParam("file") MultipartFile file,
@RequestParam String orderId,
@RequestParam String title,
@RequestParam String description)
{
String filePath = storageService.store(file);
Optional<Order> temporaryOrder = orderRepository.findById(orderId);
if(temporaryOrder.isPresent())
{
Order order = temporaryOrder.get();
List<Attachment> attachments = order.getAttachments();
attachments.add(new Attachment(title, description, filePath));
order.setAttachments(attachments);
orderRepository.save(order);
}
}
Thank you in advance.
asked Nov 7 at 21:37
xarekx
22
22
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53198209%2fupload-image-and-text-from-android-to-spring-boot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown