public class UploadFile {
Set up Access_key and Secret_key for your account
String Access_key = "Akey";
String Secret_key = "Skey";
The space to upload
String bucketname = "bucketname";//
Download path (the outer chain in the space is copied over)
String Downpath = "http://o6wcyzstb.bkt.clouddn.com/";
Key configuration
Auth Auth = auth.create (Access_key, Secret_key);
Create an Upload object
UploadManager UploadManager = new UploadManager ();
Bulk Download files
public void Download () throws IOException {
Instantiate a Bucketmanager object
Bucketmanager Bucketmanager = new Bucketmanager (auth);
Filelistiterator flit = Bucketmanager.createfilelistiterator (bucketname, "temp");//Temp here, Replace the string with the name of the file you want to download with a common letter (equivalent to the meaning of like)
String path = "";
while (Flit.hasnext ()) {
Fileinfo[] fi = Flit.next ();
for (int i=0;i<fi.length;i++) {
Path = Downpath + Fi[i].key;
String Downloadrul = Auth.privatedownloadurl (path,3600);
URL url = new URL (downloadrul);
String filename = Fi[i].key.replaceall ("/", "-");//This is the replacement of the file name with the-
File OutFile = new file ("d:\\shipin\\" +filename);//location where the download is stored
OutputStream OS = new FileOutputStream (outFile);
InputStream is = Url.openstream ();
byte[] buff = new byte[1024];
while (true) {
int readed = Is.read (buff);
if (readed = =-1) {
Break
}
byte[] temp = new byte[readed];
System.arraycopy (buff, 0, temp, 0, readed);
Os.write (temp);
}
Is.close ();
Os.close ();
}
}
}
}
Seven Qiniu store bulk download files