use of run.halo.app.model.enums.AttachmentType in project halo by ruibaby.
the class AttachmentServiceImpl method upload.
@Override
public Attachment upload(MultipartFile file) {
Assert.notNull(file, "Multipart file must not be null");
AttachmentType attachmentType = getAttachmentType();
log.debug("Starting uploading... type: [{}], file: [{}]", attachmentType, file.getOriginalFilename());
// Upload file
UploadResult uploadResult = fileHandlers.upload(file, attachmentType);
log.debug("Attachment type: [{}]", attachmentType);
log.debug("Upload result: [{}]", uploadResult);
// Build attachment
Attachment attachment = new Attachment();
attachment.setName(uploadResult.getFilename());
// Convert separator
attachment.setPath(HaloUtils.changeFileSeparatorToUrlSeparator(uploadResult.getFilePath()));
attachment.setFileKey(uploadResult.getKey());
attachment.setThumbPath(uploadResult.getThumbPath());
attachment.setMediaType(uploadResult.getMediaType().toString());
attachment.setSuffix(uploadResult.getSuffix());
attachment.setWidth(uploadResult.getWidth());
attachment.setHeight(uploadResult.getHeight());
attachment.setSize(uploadResult.getSize());
attachment.setType(attachmentType);
log.debug("Creating attachment: [{}]", attachment);
// Create and return
return create(attachment);
}
use of run.halo.app.model.enums.AttachmentType in project halo by halo-dev.
the class AttachmentServiceImpl method upload.
@Override
public Attachment upload(MultipartFile file) {
Assert.notNull(file, "Multipart file must not be null");
AttachmentType attachmentType = getAttachmentType();
log.debug("Starting uploading... type: [{}], file: [{}]", attachmentType, file.getOriginalFilename());
// Upload file
UploadResult uploadResult = fileHandlers.upload(file, attachmentType);
log.debug("Attachment type: [{}]", attachmentType);
log.debug("Upload result: [{}]", uploadResult);
// Build attachment
Attachment attachment = new Attachment();
attachment.setName(uploadResult.getFilename());
// Convert separator
attachment.setPath(HaloUtils.changeFileSeparatorToUrlSeparator(uploadResult.getFilePath()));
attachment.setFileKey(uploadResult.getKey());
attachment.setThumbPath(uploadResult.getThumbPath());
attachment.setMediaType(uploadResult.getMediaType().toString());
attachment.setSuffix(uploadResult.getSuffix());
attachment.setWidth(uploadResult.getWidth());
attachment.setHeight(uploadResult.getHeight());
attachment.setSize(uploadResult.getSize());
attachment.setType(attachmentType);
log.debug("Creating attachment: [{}]", attachment);
// Create and return
return create(attachment);
}
use of run.halo.app.model.enums.AttachmentType in project halo-plugin-experimental by guqing.
the class AttachmentServiceImpl method upload.
@Override
public Attachment upload(MultipartFile file) {
Assert.notNull(file, "Multipart file must not be null");
AttachmentType attachmentType = getAttachmentType();
log.debug("Starting uploading... type: [{}], file: [{}]", attachmentType, file.getOriginalFilename());
// Upload file
UploadResult uploadResult = fileHandlers.upload(file, attachmentType);
log.debug("Attachment type: [{}]", attachmentType);
log.debug("Upload result: [{}]", uploadResult);
// Build attachment
Attachment attachment = new Attachment();
attachment.setName(uploadResult.getFilename());
// Convert separator
attachment.setPath(HaloUtils.changeFileSeparatorToUrlSeparator(uploadResult.getFilePath()));
attachment.setFileKey(uploadResult.getKey());
attachment.setThumbPath(uploadResult.getThumbPath());
attachment.setMediaType(uploadResult.getMediaType().toString());
attachment.setSuffix(uploadResult.getSuffix());
attachment.setWidth(uploadResult.getWidth());
attachment.setHeight(uploadResult.getHeight());
attachment.setSize(uploadResult.getSize());
attachment.setType(attachmentType);
log.debug("Creating attachment: [{}]", attachment);
// Create and return
return create(attachment);
}
Aggregations