|
@@ -1,6 +1,12 @@
|
|
|
package com.yaoyicloud.ai.pipeline.fc;
|
|
package com.yaoyicloud.ai.pipeline.fc;
|
|
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.io.InputStream;
|
|
|
|
|
+import java.io.InputStreamReader;
|
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
|
+import java.nio.file.Paths;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import com.aliyun.fc.runtime.Context;
|
|
import com.aliyun.fc.runtime.Context;
|
|
|
import com.aliyun.fc.runtime.PojoRequestHandler;
|
|
import com.aliyun.fc.runtime.PojoRequestHandler;
|
|
@@ -9,8 +15,21 @@ public class ReadOssTestDataHandler implements PojoRequestHandler<ReadOssTestDat
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public OssTestDataSet handleRequest(ReadOssTestDataRequest request, Context context) {
|
|
public OssTestDataSet handleRequest(ReadOssTestDataRequest request, Context context) {
|
|
|
- System.out.println("Listing the files with prefix " + request.getOssPrefix());
|
|
|
|
|
- return new OssTestDataSet(List.of(request.getOssPrefix() + "1.jpg", request.getOssPrefix() + "2.jpg"));
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream("mountPath.txt");
|
|
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
|
|
|
|
+ String line = reader.readLine();
|
|
|
|
|
+ if (line == null || line.isBlank()) {
|
|
|
|
|
+ throw new RuntimeException("mountPath file not found");
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("Listing the files with prefix " + line);
|
|
|
|
|
+ return new OssTestDataSet(
|
|
|
|
|
+ Files.find(Paths.get(line, request.getOssPrefix()),Integer.MAX_VALUE, (p, attr) -> attr.isRegularFile())
|
|
|
|
|
+ .map(p -> p.toString()).collect(Collectors.toList()));
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|