use of com.salesmanager.shop.model.content.ContentFile in project shopizer by shopizer-ecommerce.
the class ContentAdministrationApi method upload.
/**
* works with file manager (javascript client)
* @param files
* @param merchantStore
* @param language
*/
@PostMapping(value = "/private/content/images/add", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE })
@ResponseStatus(HttpStatus.CREATED)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public FileStatus upload(@RequestParam(value = "qqfile", required = true) MultipartFile qqfile, @RequestParam(value = "qquuid", required = true) String qquuid, @RequestParam(value = "qqfilename", required = true) String qqfilename, @RequestParam(value = "qqtotalfilesize", required = false) Long qqtotalfilesize, @RequestParam(value = "parentPath", required = false) String parentPath, @RequestParam(value = "qqpartindex", required = false) Integer qqpartindex, @RequestParam(value = "qqtotalparts", required = false) Integer qqtotalparts, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
if (!fileNameUtils.validFileName(qqfilename)) {
FileStatus fs = new FileStatus();
fs.setError("Invalid filename");
fs.setSuccess(false);
return fs;
}
ContentFile cf = new ContentFile();
cf.setContentType(qqfile.getContentType());
cf.setName(qqfilename);
try {
cf.setFile(qqfile.getBytes());
contentFacade.addContentFile(cf, merchantStore.getCode());
return new FileStatus();
} catch (IOException e) {
// throw new ServiceRuntimeException("Error while getting file bytes");
LOGGER.error("Error when uploadging file", e);
FileStatus fs = new FileStatus();
fs.setError(e.getMessage());
fs.setSuccess(false);
return fs;
}
}
use of com.salesmanager.shop.model.content.ContentFile in project shopizer by shopizer-ecommerce.
the class ContentApi method upload.
/**
* Need type, name and entity
*
* @param file
*/
@PostMapping(value = "/private/file")
@ResponseStatus(HttpStatus.CREATED)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public void upload(@RequestParam("file") MultipartFile file, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
ContentFile f = new ContentFile();
f.setContentType(file.getContentType());
f.setName(file.getOriginalFilename());
try {
f.setFile(file.getBytes());
} catch (IOException e) {
throw new ServiceRuntimeException("Error while getting file bytes");
}
contentFacade.addContentFile(f, merchantStore.getCode());
}
use of com.salesmanager.shop.model.content.ContentFile in project shopizer by shopizer-ecommerce.
the class ContentApi method uploadMultipleFiles.
@PostMapping(value = "/private/files", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE })
@ResponseStatus(HttpStatus.CREATED)
@ApiImplicitParams({ // required = true,dataType = "MultipartFile",allowMultiple = true),
@ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public void uploadMultipleFiles(@RequestParam(value = "file[]", required = true) MultipartFile[] files, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
for (MultipartFile f : files) {
ContentFile cf = new ContentFile();
cf.setContentType(f.getContentType());
cf.setName(f.getName());
try {
cf.setFile(f.getBytes());
contentFacade.addContentFile(cf, merchantStore.getCode());
} catch (IOException e) {
throw new ServiceRuntimeException("Error while getting file bytes");
}
}
}
Aggregations