简体   繁体   English

在 java spring 引导应用程序运行期间从资源文件夹创建和访问 zip 文件

[英]Create and access zip file from resource folder during runtime in java spring boot application

My requirement is, I have to create one zip file and store in resource folder and once it's created, i have to pass this zip file to another api(which one will accept only.zip file as a input)through rest template.我的要求是,我必须创建一个 zip 文件并存储在资源文件夹中,一旦它被创建,我必须通过 rest 模板将这个 zip 文件传递给另一个 api(它只接受 zip 文件作为输入)。

Now my problem is after creating zip file im not able to access it.现在我的问题是在创建 zip 文件后我无法访问它。 I think this is because the file is not available in target folder.我认为这是因为该文件在目标文件夹中不可用。

How to solve this problem?如何解决这个问题呢?

Note: all these activities should happen in a single call.注意:所有这些活动都应该在一次调用中发生。

Technology: java 11, spring boot, maven Latest技术:java 11、spring开机、maven最新

the resource folder is normaly part of a jar. i would create a temp folder (java.nio.file.Files.createTempDirectory()) and store the zip there.资源文件夹通常是 jar 的一部分。我会创建一个临时文件夹 (java.nio.file.Files.createTempDirectory()) 并将 zip 存储在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Spring Boot将zip文件从应用程序Resource文件夹复制到目标 - Copying zip File from application Resource folder to target using spring boot Spring Boot应用程序中的资源访问 - Resource access in Spring Boot application 如何在 Spring Boot 中访问 src/main/resources/ 文件夹中的资源文件 - How to access a resource file in src/main/resources/ folder in Spring Boot 从资源文件夹读取文件总是在 Spring Boot 应用程序中给出 Inputstream 为空 - Read file from resource folder always giving Inputstream is null in spring boot application Java 模块 - 简单 Spring 引导应用程序,创建自定义运行时 - Java Modules - Simple Spring Boot application, create custom runtime 在运行时从 spring 引导中的外部文件夹加载 jar 文件 - Loading jar file at runtime from an external folder in spring boot Spring 启动应用程序中的 Java 运行时错误 - Java runtime error in Spring Boot application 如何访问 spring 启动应用程序中的文件夹 - How to Access folder in spring boot application 写入ZIP文件的文件仅在运行时可用[Java] - File written to ZIP file available only during runtime [Java] 如何在运行时编辑 spring 启动 kubernetes 应用程序中的 configmap 配置 - How to edit configmap configuration in spring boot kubernetes application during runtime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM