[英]How to upload multiple files from local storage to the azure blob storage using .sh file that located in azure webapp
I need to upload some *.csv files to the azure blob storage from the.sh file which is located in azure linux webapp. 是否有可能做到这一点或我该怎么做。 如果可能的话,有人可以提供示例代码。
当然,您可以使用Runtime.getRunTime().exec在 Java 代码中运行 shell 脚本,示例代码如下:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RunningSS {
public static void main(String[] args) {
Process p;
try {
String[] cmd = { "sh", "/home/adb/Documents/test.sh"};
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(
p.getInputStream()));
String line;
while((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
要在 shell 脚本中上传文件,可以使用 Azure CLI 命令或azcopy 。 例如,如果您要将文件上传到 Azure 存储文件,则 CLI 命令为az storage file upload
,但如果您使用 CLI,则需要先安装它。 请参阅安装 Azure CLI 。
我不推荐REST API,太复杂了。 如果你不介意,你可以试一试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.