Skip to content
Snippets Groups Projects
Commit 055b0b25 authored by ella's avatar ella
Browse files

version fonctionnel du telechargement

parent c6c9da6e
No related branches found
No related tags found
No related merge requests found
Pipeline #6499 passed with stages
in 1 minute and 4 seconds
......@@ -8,6 +8,7 @@ package fr.cines.pacit.transfer.impl;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.channels.Channels;
......@@ -25,14 +26,17 @@ public class TransferCamelImpl {
String fileName = "vitam-data-test-master";
public void downloadFile(String url, String fileName) throws IOException
public void downloadFile(String url, String localPath) throws IOException
{
URL ulr = new URL(url);
FileOutputStream fileOutputStream = new FileOutputStream(fileName);
FileChannel fileChannel = fileOutputStream.getChannel();
ReadableByteChannel readableByteChannel = Channels.newChannel(ulr.openStream());
fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
HttpURLConnection connection = (HttpURLConnection) ulr.openConnection();
connection.setRequestProperty("accept", "*/*");
ReadableByteChannel readableFileChannel = Channels.newChannel(connection.getInputStream());
FileOutputStream fos = new FileOutputStream(localPath + "//vitam-data-test.zip");
fos.getChannel().transferFrom(readableFileChannel, 0, Long.MAX_VALUE);
}
......
url=https://dci-gitlab.cines.fr/dad/vitam-data-test/-/archive/master/vitam-data-test-master.zip
localPath=file:/C:/Users/ella/Desktop/testTransfer/
\ No newline at end of file
localPath=C:/Users/ella/Desktop/TestTranfer2/
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment