Skip to content

Instantly share code, notes, and snippets.

@kakashysen
Created October 9, 2019 06:31
Show Gist options
  • Select an option

  • Save kakashysen/3e7095f9d6ac4f4c5fb9d430a40dfaa9 to your computer and use it in GitHub Desktop.

Select an option

Save kakashysen/3e7095f9d6ac4f4c5fb9d430a40dfaa9 to your computer and use it in GitHub Desktop.
Download files from azure
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Main {
public static final String KEY = "?sv=2018-03-28&ss=b&srt=sco&sp=rwdlac&se=2019-12-31T22:00:21Z&st=2019-05-31T14:00:21Z&spr=https&sig=AT8ixMUsGZUmHO7drjjamIfReLkBDbwl3xZxfNw%2B%2F88%3D";
public static void main(String args[]) {
ExecutorService executorService = Executors.newFixedThreadPool(100);
List<String> paths = Arrays.asList("https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200036360.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200036452.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200036544.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200036636.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200036728.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200036902.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200039279.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200039378.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200039460.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200039552.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200039644.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200041470.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200041654.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200041746.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200041838.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200041920.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200042019.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200042101.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200042194.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200042286.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200042378.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044082.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044174.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044266.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044358.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044440.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044532.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044716.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044808.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200044891.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200046611.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200046703.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-27/33165200049254.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-28/0033165200051769.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-28/33165200036810.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-28/33165200041562.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-28/33165200044624.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-29/33165200034588.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-29/33165200057433.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-30/33165200039095.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-7-30/33165200039187.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-1/33165200039736.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-1/33190400117373.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-1/33190400117472.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-10/0033190400117694.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-10/33190400117083.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-10/33190400125279.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-11/33190400120373.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-11/33190400120663.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-11/33190400120755.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-11/33190400120847.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-11/33190400121028.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-11/33190400121110.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-11/33190400121202.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-11/33190400121295.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-12/0033190400123121.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-12/33165200057211.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400117809.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400117892.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400118028.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400118165.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400118264.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400118356.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400118455.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400118561.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/0033190400119872.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-13/33190400119674.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-16/33190400120465.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-16/33190400120564.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-16/33190400120939.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-17/33190400128232.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-2/33190400123824.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-22/33190400129314.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-26/33190400125361.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/0033165200033840.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/0033165200034489.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/0033190400123411.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33165200033949.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33165200034038.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33165200034144.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33165200034236.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33165200034359.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33190400122353.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33190400123510.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33190400123626.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33190400123718.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33190400123916.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-3/33190400124012.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-4/0033190400123305.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-4/33190400117182.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-4/33190400117274.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-4/33190400123213.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-5/0033190400122742.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-5/33190400122452.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-5/33190400122551.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-5/33190400122643.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-5/33190400122834.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-5/33190400122926.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-8-5/33190400123015.png",
"https://computecdatacourrier.blob.core.windows.net/imagenes/ax100/imagenes/FORMS-2016-9-2/33190400126672.png");
for (int i = 0; i < paths.size(); i++) {
String pathAzure = paths.get(i);
String command[] = {"/Users/japonte/Downloads/azcopy_darwin_amd64_10.2.1/azcopy","copy",pathAzure+KEY, "/tmp/imgs/"+getImageName(pathAzure)};
MyThread thread = new MyThread(command);
executorService.submit(thread);
}
executorService.shutdown();
while (!executorService.isTerminated()) {}
System.out.println("Finisehd!!!");
}
private static String getImageName(String path) {
String[] temp = path.split("/");
String result = temp[temp.length-1];
return result;
}
}
class MyThread extends Thread {
private String[] command;
MyThread(String[] command) {
this.command = command;
}
@Override
public void run() {
try {
Process p = Runtime.getRuntime().exec(command);
System.out.println("Waiting...");
p.waitFor();
if(p != null) {
InputStream is = p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
while ((line = br.readLine()) != null) {
// System.out.println(line);
}
System.out.println("Finished thread "+ Thread.currentThread().getName());
}else {
System.out.println("p == null");
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment