Seven Qiniu store bulk download files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.