Gianpaolo Coro 2016-02-01 22:07:37 +00:00
parent 0eec164e5c
commit d8f7c33be7
1 changed files with 18 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
public class StorageUtils {
public static void downloadInputFile(String fileurl, String destinationFile) throws Exception{
downloadInputFile(fileurl, destinationFile, false);
}
@ -52,6 +53,23 @@ public class StorageUtils {
out.close();
}
public static String uploadFilesOnStorage(String scope, String user, String localFolder, String remoteFolder, String file) throws Exception {
try {
ScopeProvider.instance.set(scope);
AnalysisLogger.getLogger().info("Loading file on scope: " + scope);
IClient client = new StorageClient(AlgorithmConfiguration.StatisticalManagerClass, AlgorithmConfiguration.StatisticalManagerService, user, AccessType.SHARED, MemoryType.VOLATILE).getClient();
String remotef = remoteFolder+file;
client.put(true).LFile(new File(localFolder,file).getAbsolutePath()).RFile(remotef);
String url = client.getUrl().RFile(remotef);
AnalysisLogger.getLogger().info("Loading finished");
System.gc();
return url;
} catch (Exception e) {
AnalysisLogger.getLogger().info("Error in uploading file: " + e.getLocalizedMessage());
throw e;
}
}
public static String uploadFilesOnStorage(String scope, String user, String localFolder, String file) throws Exception {
try {
ScopeProvider.instance.set(scope);