我已经完成了容器设置和文件重命名步骤,这不是问题,但上传后,我 Azure 域上 blob 存储容器中的文件大小显示为 0 字节。
我尝试交替将文件转换为 FileInputStream 并将其作为流上传,但它仍然以相同的方式产生。
fileName=event.getFilename(); //fileName is e.g eod1234.csv
String tempdir = System.getProperty("java.io.tmpdir");
file= new File(tempdir+File.separator+fileName); //
try {
PipedOutputStream pos = new PipedOutputStream();
stream= new PipedInputStream(pos);
buffer = new byte[stream.available()];
stream.read(buffer);
FileInputStream fils = new FileInputStream(file);
int content = 0;
while((content = fils.read()) != -1){
System.out.println((char)content);
}
//Outputstream was written as a test previously but didn't work
OutputStream outStream = new FileOutputStream(file);
outStream.write(buffer);
outStream.close();
// container name is "testing1"
CloudBlockBlob blob = container.getBlockBlobReference(fileName);
if(fileName.length() > 0){
blob.upload(fils,file.length()); //this is testing with fileInputStream
blob.uploadFromFile(fileName); //preferred, just upload from file
}
}
没有显示任何错误消息,只是我们知道该文件涉及 blob 存储并显示大小为 0 字节。这是一种单向过程,仅上传 CSV 格式的文件。在 blob 容器中,它应该显示每个上传的文件大小为 1-5 KB。
SMILET
HUH函数
慕尼黑的夜晚无繁华
相关分类