Upload file with different name

I want to upload images & send with different names.

Send images successfully but with the original name:

httpPostuplod = new HttpPost(URL);
MultipartEntity multiPart = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

for (int i = 0; i < imglist.size(); i++) {      
    System.out.println(imglist.get(i));
    File file = new File(imglist.get(i));

    // multiPart.addPart("IMG_"+Constants_Fix.postImgcount+".png", new FileBody(new File(imglist.get(i))));
    ContentBody cbFile = new FileBody(file, "image/png");

    multiPart.addPart("IMG_"+Constants_Fix.postImgcount+".png",cbFile);

    Constants_Fix.postImgcount++;
}

httpPostuplod.setEntity(multiPart);

HttpResponse resuplod = httpclient.execute(httpPostuplod);

Answers


/** * Generated Random Number without specifying any range */

    Random rand = new Random();
            int numNoRange = rand.nextInt();
            String number = String.valueOf(numNoRange);

File imageFile =  new File(path,number+"img.jpg");

generate a Random Number and append the number to your image name


Need Your Help

Inserting a table under the legend in a ggplot2 and saving everything to a file

r ggplot2

I have the following data.frame which I would like to plot with ggplot2:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.