Subversion Repositories SmartDukaan

Rev

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

Rev 25412 Rev 25413
Line 92... Line 92...
92
 
92
 
93
	private String getFileName(int entityId, String description, String extension) {
93
	private String getFileName(int entityId, String description, String extension) {
94
		List<Item> items = itemRepository.selectAllByCatalogItemId(entityId);
94
		List<Item> items = itemRepository.selectAllByCatalogItemId(entityId);
95
		String imageString = getMediaPrefix(items.get(0).getItemDescriptionNoColor() + " " + description) + "-"
95
		String imageString = getMediaPrefix(items.get(0).getItemDescriptionNoColor() + " " + description) + "-"
96
				+ LocalDateTime.now().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30));
96
				+ LocalDateTime.now().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30));
97
		return imageString.replaceAll("\\s+", " ") + "." + extension;
97
		return imageString + "." + extension;
98
	}
98
	}
99
 
99
 
100
	@PostMapping(value = "/content/upload")
100
	@PostMapping(value = "/content/upload")
101
	public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
101
	public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
102
			throws Exception {
102
			throws Exception {
Line 293... Line 293...
293
		} catch (Exception e) {
293
		} catch (Exception e) {
294
			System.out.println(destinationPath + "/" + folderName + " not found");
294
			System.out.println(destinationPath + "/" + folderName + " not found");
295
		}
295
		}
296
 
296
 
297
		// else create a directory
297
		// else create a directory
298
		if (attrs != null) {
298
		if (attrs == null) {
299
			channelSftp.rmdir(folderName);
299
			channelSftp.mkdir(folderName);
-
 
300
			channelSftp.chmod(0755, ".");
300
		}
301
		}
301
 
-
 
302
		channelSftp.mkdir(folderName);
-
 
303
		channelSftp.cd(folderName);
302
		channelSftp.cd(folderName);
304
 
-
 
305
		channelSftp.chmod(0644, ".");
303
		channelSftp.rm("*");
306
 
304
 
307
		for (Map.Entry<String, InputStream> streamsFileEntry : streamsFileMap.entrySet()) {
305
		for (Map.Entry<String, InputStream> streamsFileEntry : streamsFileMap.entrySet()) {
308
			channelSftp.put(streamsFileEntry.getValue(), streamsFileEntry.getKey(), ChannelSftp.OVERWRITE);
306
			channelSftp.put(streamsFileEntry.getValue(), streamsFileEntry.getKey(), ChannelSftp.OVERWRITE);
309
		}
307
		}
310
 
308