I apologize for the confusion, let me explain properly what my requirment is.
I am Creating an interface on Oracle APEX for the purpose of client interaction, which means that this will be the UI for Clients. The Flow goes like this. The client is able to download a Template file(Excel file), Then the client can fill thier own content into the template file. Now This file needs to be processed, so we have the program which processes this in a OCI instance. It is a Springboot Program which processes the file from a directory folder called 'Target' inside the OCI instance.
The issue i have is that i cant get the filled template file into the target folder inside the OCI instance. I have written a program which i use to upload the file and exposed its API to the/uploadfile endpoint.
I created a Filebrowser item on Oracle APEX and wrote the process in PL/SQL with the post request and the API URL. Unfortunerly i cant find the issue.
Let me summarize,
the Client intially gets the page to download the template.
They fill in the template
They go to the next page and use the filebrowser item to upload the filled template
They click the Submit/Process button.
The File reaches the OCI instance directory inside the folder named 'Target'
The issue i have is the program i wrote is working properly, that is, uploading the file to the OCI instance via postman and Simple HTML webpage. But Replicating it in Apex is not working and im not sure why
I'm not sure how to answer if it is a one off process or a regular job. i guess it repeats as much the client will require.
I believe the last comment, Uploading a file from the clients local machine from a apex page and calling rest api to bring this file into my cloud OCI instance, is precisely what i need.
I will provide any more data as needed, I have been stuck for a month or two and tried everything i know(even though i am new).
This is the small program i use to upload the file
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@Controller
public class FileUploadController {
private static final String UPLOAD_FOLDER = "/home/opc/target"; // Replace with your actual upload folder path
@PostMapping("/uploadfile")
public String uploadFile(@RequestParam("file") MultipartFile file, RedirectAttributes redirectAttributes) {
if (file.isEmpty()) {
redirectAttributes.addFlashAttribute("message", "Please select a file to upload");
return "redirect:/";
}
try {
byte[] bytes = file.getBytes();
Path filePath = Paths.get(UPLOAD_FOLDER, file.getOriginalFilename());
Files.write(filePath, bytes);
redirectAttributes.addFlashAttribute("message", "File uploaded successfully");
} catch (IOException e) {
e.printStackTrace();
redirectAttributes.addFlashAttribute("message", "Error uploading the file");
}
return "redirect:/";
}
}