| Line 87... |
Line 87... |
| 87 |
public static final int Warranty = 6;
|
87 |
public static final int Warranty = 6;
|
| 88 |
public static final int Package_Contents = 7;
|
88 |
public static final int Package_Contents = 7;
|
| 89 |
private static final String IMAGE_REMOTE_DIR = "/var/www/dtrdashboard/uploads/campaigns/";
|
89 |
private static final String IMAGE_REMOTE_DIR = "/var/www/dtrdashboard/uploads/campaigns/";
|
| 90 |
private static final String IMAGE_STATIC_SERVER_URL = "https://images.smartdukaan.com/uploads/campaigns";
|
90 |
private static final String IMAGE_STATIC_SERVER_URL = "https://images.smartdukaan.com/uploads/campaigns";
|
| 91 |
|
91 |
|
| 92 |
//private static final String REMOTE_DIR = "/var/www/static.saholic.com/images/media/";
|
92 |
private static final String REMOTE_DIR = "/var/www/static.saholic.com/images/media/";
|
| 93 |
private static final String REMOTE_DIR = "/tmp";
|
93 |
//private static final String REMOTE_DIR = "/tmp";
|
| 94 |
private static final String STATIC_SERVER_URL = "https://static%d.smartdukaan.com/images/media/";
|
94 |
private static final String STATIC_SERVER_URL = "https://static%d.smartdukaan.com/images/media/";
|
| 95 |
|
95 |
|
| 96 |
private static final String THUMBNAIL = "thumbnail";
|
96 |
private static final String THUMBNAIL = "thumbnail";
|
| 97 |
private static final String ICON = "icon";
|
97 |
private static final String ICON = "icon";
|
| 98 |
private static final String DEFAULT = "default";
|
98 |
private static final String DEFAULT = "default";
|
| Line 122... |
Line 122... |
| 122 |
public String uploadMediaContent(HttpServletRequest request, @RequestBody EntityMediaPojo entityMediaPojo,
|
122 |
public String uploadMediaContent(HttpServletRequest request, @RequestBody EntityMediaPojo entityMediaPojo,
|
| 123 |
Model model) throws Exception {
|
123 |
Model model) throws Exception {
|
| 124 |
ContentPojo contentPojo = mongoClient.getEntityById(entityMediaPojo.getEntityId());
|
124 |
ContentPojo contentPojo = mongoClient.getEntityById(entityMediaPojo.getEntityId());
|
| 125 |
Map<String, InputStream> fileStreamsMap = getStreamFileMap(contentPojo, entityMediaPojo);
|
125 |
Map<String, InputStream> fileStreamsMap = getStreamFileMap(contentPojo, entityMediaPojo);
|
| 126 |
LOGGER.info("fileStreamsMap {}, " + fileStreamsMap.keySet());
|
126 |
LOGGER.info("fileStreamsMap {}, " + fileStreamsMap.keySet());
|
| 127 |
uploadFiles(fileStreamsMap, entityMediaPojo.getEntityId());
|
127 |
uploadContentFiles(fileStreamsMap, entityMediaPojo.getEntityId());
|
| 128 |
mongoClient.persistEntity(contentPojo);
|
128 |
mongoClient.persistEntity(contentPojo);
|
| 129 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
129 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 130 |
return "response";
|
130 |
return "response";
|
| 131 |
}
|
131 |
}
|
| 132 |
|
132 |
|
| Line 172... |
Line 172... |
| 172 |
|
172 |
|
| 173 |
model.addAttribute("documents", du);
|
173 |
model.addAttribute("documents", du);
|
| 174 |
return "image-url";
|
174 |
return "image-url";
|
| 175 |
}
|
175 |
}
|
| 176 |
|
176 |
|
| 177 |
private void uploadFile(Map<String, InputStream> fileStreamsMap) throws Exception {
|
- |
|
| 178 |
ChannelSftp channelSftp = setupJsch();
|
- |
|
| 179 |
channelSftp.connect();
|
- |
|
| 180 |
this.fileUpload(channelSftp, fileStreamsMap, IMAGE_REMOTE_DIR + "");
|
- |
|
| 181 |
channelSftp.exit();
|
- |
|
| 182 |
}
|
- |
|
| 183 |
|
177 |
|
| 184 |
private void fileUpload(ChannelSftp channelSftp, Map<String, InputStream> streamsFileMap, String destinationPath)
|
178 |
private void fileUpload(ChannelSftp channelSftp, Map<String, InputStream> streamsFileMap, String destinationPath)
|
| 185 |
throws SftpException, FileNotFoundException {
|
179 |
throws SftpException, FileNotFoundException {
|
| 186 |
|
180 |
|
| 187 |
channelSftp.cd(destinationPath);
|
181 |
channelSftp.cd(destinationPath);
|
| Line 342... |
Line 336... |
| 342 |
jschSession.setConfig("StrictHostKeyChecking", "no");
|
336 |
jschSession.setConfig("StrictHostKeyChecking", "no");
|
| 343 |
jschSession.connect();
|
337 |
jschSession.connect();
|
| 344 |
return (ChannelSftp) jschSession.openChannel("sftp");
|
338 |
return (ChannelSftp) jschSession.openChannel("sftp");
|
| 345 |
}
|
339 |
}
|
| 346 |
|
340 |
|
| - |
|
341 |
private void uploadFile(Map<String, InputStream> fileStreamsMap) throws Exception {
|
| - |
|
342 |
ChannelSftp channelSftp = setupJsch();
|
| - |
|
343 |
channelSftp.connect();
|
| - |
|
344 |
this.fileUpload(channelSftp, fileStreamsMap, IMAGE_REMOTE_DIR + "");
|
| - |
|
345 |
channelSftp.exit();
|
| - |
|
346 |
}
|
| - |
|
347 |
|
| 347 |
private void uploadFiles(Map<String, InputStream> fileStreamsMap, int entityId) throws Exception {
|
348 |
private void uploadContentFiles(Map<String, InputStream> fileStreamsMap, int entityId) throws Exception {
|
| 348 |
ChannelSftp channelSftp = setupJsch();
|
349 |
ChannelSftp channelSftp = setupJsch();
|
| 349 |
channelSftp.connect();
|
350 |
channelSftp.connect();
|
| 350 |
this.folderUpload(channelSftp, fileStreamsMap, REMOTE_DIR, entityId + "");
|
351 |
this.folderUpload(channelSftp, fileStreamsMap, REMOTE_DIR, entityId + "");
|
| 351 |
channelSftp.exit();
|
352 |
channelSftp.exit();
|
| 352 |
}
|
353 |
}
|