Subversion Repositories SmartDukaan

Rev

Rev 30388 | Rev 30392 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30388 Rev 30389
Line 135... Line 135...
135
							List<Order> orders = invoiceOrdersMap.get(invoice);
135
							List<Order> orders = invoiceOrdersMap.get(invoice);
136
							String invoicePath = this.getInvoicePath(orders.get(0));
136
							String invoicePath = this.getInvoicePath(orders.get(0));
137
							HttpResponse response = restClient.getResponse("http://50.116.3.101/" + invoicePath, null, headersMap);
137
							HttpResponse response = restClient.getResponse("http://50.116.3.101/" + invoicePath, null, headersMap);
138
							ZipEntry zipEntry = new ZipEntry(invoice + ".pdf");
138
							ZipEntry zipEntry = new ZipEntry(invoice + ".pdf");
139
							zipOut.putNextEntry(zipEntry);
139
							zipOut.putNextEntry(zipEntry);
140
							byte[] bytes = new byte[(int) response.getEntity().getContentLength()];
140
							int contentLength = (int) response.getEntity().getContentLength();
-
 
141
							byte[] bytes = new byte[contentLength];
141
							response.getEntity().getContent().read(bytes);
142
							response.getEntity().getContent().read(bytes);
142
							zipOut.write(bytes, 0, (int) response.getEntity().getContentLength());
143
							zipOut.write(bytes, 0, contentLength);
143
						}
144
						}
144
						byte[] byteArray = fos.toByteArray();
145
						byte[] byteArray = fos.toByteArray();
145
						headers.set("Content-Type", "application/octet-stream");
146
						headers.set("Content-Type", "application/octet-stream");
146
						headers.set("Content-disposition", "inline; filename=invoices.zip");
147
						headers.set("Content-disposition", "attachment; filename=invoices.zip");
147
						headers.setContentLength(byteArray.length);
148
						headers.setContentLength(byteArray.length);
148
						zipOut.close();
149
						zipOut.close();
149
						fos.close();
150
						fos.close();
150
						return new ResponseEntity<>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
151
						return new ResponseEntity<>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
151
					}
152
					}