Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void vai (HttpServletRequest request, HttpServletResponse response)
- Map <String,String> subFolders = new HashMap <String,String>();
- Map <String,String> subFoldersP = new HashMap <String,String>();
- Map <String,Path> subFoldersPath = new HashMap <String,Path>();
- String cosa = "";
- String nome = "";
- String percorso = "";
- int corrente,massimo = 0;
- int whatToShow = 0 ;
- Path nom = Paths.get(UPLOAD_DIRECTORY) ;
- System.out.println("QueryString : " + request.getQueryString() + " ContentType : " + request.getContentType());
- response.setContentType ("text/event-stream;charset=UTF-8"); //("text/html");
- response.setContentType("Cache-Control: no-cache");
- PrintWriter out = response.getWriter();
- //process only if its multipart content
- if(ServletFileUpload.isMultipartContent(request)){
- try {
- String Host = "third-party";
- String Username = "someuser";
- String Password = "somePWD";
- String handle = "";
- List<FileItem> multiparts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
- massimo = multiparts.size();
- corrente=0;
- for(FileItem item : multiparts){
- corrente ++;
- whatToShow = ((corrente*100)/massimo);
- if(!item.isFormField()){
- handle = insertIntoThirdPart(item,nom,subFolders,subFoldersP,subFoldersPath,"myDest");
- } else {
- nome = item.getString();
- System.out.println("Ricevuto dal client " + nome + " e le mappe hanno dimensione " + subFolders.size() + " " + subFoldersP.size() + " " +subFoldersPath.size() );
- nom = Paths.get(nome);
- percorso = nom.toString();
- percorso = percorso.substring(0, (percorso.length() - nom.getFileName().toString().length()));
- System.out.println("Passato alla routine " + percorso);
- nom = Paths.get(percorso);
- System.out.println("come " + nom.toString());
- cosa = cosa + item.getString()+"<BR>";
- }
- }
- out.write("Files processing terminated...");
- out.flush();
- subFolders.clear();
- subFoldersP.clear();
- subFoldersPath.clear();
- corrente = 0;
- //File uploaded successfully
- } catch (Exception ex) {
- out.write("File Upload Failed due to " + ex); //mannaggia alla pupazza !!
- }
- }else{
- out.write("Sorry, this function in restricted for internal purposes"); // eh no ciccio !
- }
- }
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- vai(request,response);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement