Search in sources :

Example 1 with AttachmentType

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);
}
Also used : AttachmentType(run.halo.app.model.enums.AttachmentType) Attachment(run.halo.app.model.entity.Attachment) UploadResult(run.halo.app.model.support.UploadResult)

Example 2 with AttachmentType

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);
}
Also used : AttachmentType(run.halo.app.model.enums.AttachmentType) Attachment(run.halo.app.model.entity.Attachment) UploadResult(run.halo.app.model.support.UploadResult)

Example 3 with AttachmentType

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);
}
Also used : AttachmentType(run.halo.app.model.enums.AttachmentType) Attachment(run.halo.app.model.entity.Attachment) UploadResult(run.halo.app.model.support.UploadResult)

Aggregations

Attachment (run.halo.app.model.entity.Attachment)3 AttachmentType (run.halo.app.model.enums.AttachmentType)3 UploadResult (run.halo.app.model.support.UploadResult)3