Add -f FILE flag support for session and service commands
All 38+ implementations now support: - session -f FILE: Upload files to /tmp/ in session container - service -f FILE: Upload files to /tmp/ in service container - service --bootstrap-file FILE: Read bootstrap script from file
This commit is contained in:
parent
a5a4f23594
commit
c6813e5a18
40 changed files with 2506 additions and 329 deletions
25
Un.java
25
Un.java
|
|
@ -210,6 +210,19 @@ public class Un {
|
|||
payload.put("vcpu", args.vcpu);
|
||||
}
|
||||
|
||||
// Add input files
|
||||
if (args.files != null && !args.files.isEmpty()) {
|
||||
List<Map<String, String>> inputFiles = new ArrayList<>();
|
||||
for (String filepath : args.files) {
|
||||
byte[] content = Files.readAllBytes(Paths.get(filepath));
|
||||
Map<String, String> fileObj = new HashMap<>();
|
||||
fileObj.put("filename", Paths.get(filepath).getFileName().toString());
|
||||
fileObj.put("content_base64", Base64.getEncoder().encodeToString(content));
|
||||
inputFiles.add(fileObj);
|
||||
}
|
||||
payload.put("input_files", inputFiles);
|
||||
}
|
||||
|
||||
System.out.println(YELLOW + "Creating session..." + RESET);
|
||||
Map<String, Object> result = apiRequest("/sessions", "POST", payload, publicKey, secretKey);
|
||||
System.out.println(GREEN + "Session created: " + result.getOrDefault("id", "N/A") + RESET);
|
||||
|
|
@ -341,6 +354,18 @@ public class Un {
|
|||
if (args.serviceBootstrap != null) {
|
||||
payload.put("bootstrap", args.serviceBootstrap);
|
||||
}
|
||||
// Add input files
|
||||
if (args.files != null && !args.files.isEmpty()) {
|
||||
List<Map<String, String>> inputFiles = new ArrayList<>();
|
||||
for (String filepath : args.files) {
|
||||
byte[] content = Files.readAllBytes(Paths.get(filepath));
|
||||
Map<String, String> fileObj = new HashMap<>();
|
||||
fileObj.put("filename", Paths.get(filepath).getFileName().toString());
|
||||
fileObj.put("content_base64", Base64.getEncoder().encodeToString(content));
|
||||
inputFiles.add(fileObj);
|
||||
}
|
||||
payload.put("input_files", inputFiles);
|
||||
}
|
||||
if (args.network != null) {
|
||||
payload.put("network", args.network);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue