當前位置: 首頁>>代碼示例>>Java>>正文


Java FileDescriptor.setSize方法代碼示例

本文整理匯總了Java中com.haulmont.cuba.core.entity.FileDescriptor.setSize方法的典型用法代碼示例。如果您正苦於以下問題:Java FileDescriptor.setSize方法的具體用法?Java FileDescriptor.setSize怎麽用?Java FileDescriptor.setSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.haulmont.cuba.core.entity.FileDescriptor的用法示例。


在下文中一共展示了FileDescriptor.setSize方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFileDescriptor

import com.haulmont.cuba.core.entity.FileDescriptor; //導入方法依賴的package包/類
@Override
public FileDescriptor getFileDescriptor(UUID fileId, String name) {
    File file = getFile(fileId);
    if (file == null) {
        return null;
    }
    Metadata metadata = AppBeans.get(Metadata.NAME);

    FileDescriptor fDesc = metadata.create(FileDescriptor.class);

    fDesc.setSize(file.length());
    fDesc.setExtension(FilenameUtils.getExtension(name));
    fDesc.setName(name);
    fDesc.setCreateDate(timeSource.currentTimestamp());

    return fDesc;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:18,代碼來源:FileUploading.java

示例2: setUp

import com.haulmont.cuba.core.entity.FileDescriptor; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    fileDescr = new FileDescriptor();
    fileDescr.setCreateDate(new Date());
    fileDescr.setSize((long) FILE_CONTENT.length());
    fileDescr.setName("AmazonFileStorageTest");
    fileDescr.setExtension("txt");

    fileDescr2 = new FileDescriptor();
    fileDescr2.setCreateDate(new Date());
    fileDescr2.setSize((long) FILE_CONTENT.length());
    fileDescr2.setName("AmazonFileStorageTest");

    fileStorageAPI = new AmazonS3FileStorage();
    fileStorageAPI.amazonS3Config = AppBeans.get(Configuration.class).getConfig(AmazonS3Config.class);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:17,代碼來源:AmazonS3FileStorageTest.java

示例3: createFileDescriptor

import com.haulmont.cuba.core.entity.FileDescriptor; //導入方法依賴的package包/類
protected FileDescriptor createFileDescriptor(@Nullable String fileName, long size) {
    FileDescriptor fd = metadata.create(FileDescriptor.class);
    if (Strings.isNullOrEmpty(fileName)) {
        fileName = fd.getId().toString();
    }
    fd.setName(fileName);
    fd.setExtension(FilenameUtils.getExtension(fileName));
    fd.setSize(size);
    fd.setCreateDate(timeSource.currentTimestamp());
    return fd;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:12,代碼來源:FileUploadController.java

示例4: getFileDescriptor

import com.haulmont.cuba.core.entity.FileDescriptor; //導入方法依賴的package包/類
protected FileDescriptor getFileDescriptor(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String name = request.getParameter("name");
    if (name == null) {
        log.error("'name' request parameter is not specified");
        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        return null;
    }

    String ext = request.getParameter("ext");
    if (ext == null) {
        log.error("'ext' request parameter is not specified");
        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        return null;
    }

    String size = request.getParameter("size");

    FileDescriptor fd = metadata.create(FileDescriptor.class);
    fd.setName(name);
    fd.setExtension(ext);
    fd.setCreateDate(timeSource.currentTimestamp());
    if (size != null) {
        fd.setSize(Long.parseLong(size));
    }

    return fd;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:28,代碼來源:FileUploadController.java

示例5: createAttachmentFileDescriptor

import com.haulmont.cuba.core.entity.FileDescriptor; //導入方法依賴的package包/類
protected FileDescriptor createAttachmentFileDescriptor(SendingAttachment attachment) {
    FileDescriptor contentFile = metadata.create(FileDescriptor.class);
    contentFile.setCreateDate(timeSource.currentTimestamp());
    contentFile.setName(attachment.getName());
    contentFile.setExtension(FilenameUtils.getExtension(attachment.getName()));
    contentFile.setSize((long) attachment.getContent().length);
    return contentFile;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:9,代碼來源:Emailer.java

示例6: createBodyFileDescriptor

import com.haulmont.cuba.core.entity.FileDescriptor; //導入方法依賴的package包/類
protected FileDescriptor createBodyFileDescriptor(SendingMessage message, byte[] bodyBytes) {
    FileDescriptor contentTextFile = metadata.create(FileDescriptor.class);
    contentTextFile.setCreateDate(timeSource.currentTimestamp());
    contentTextFile.setName("Email_" + message.getId() + "." + BODY_FILE_EXTENSION);
    contentTextFile.setExtension(BODY_FILE_EXTENSION);
    contentTextFile.setSize((long) bodyBytes.length);
    return contentTextFile;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:9,代碼來源:Emailer.java

示例7: fileUploadSucceed

import com.haulmont.cuba.core.entity.FileDescriptor; //導入方法依賴的package包/類
@Override
public void fileUploadSucceed(FileUploadField.FileUploadSucceedEvent e) {
    FileDescriptor fd = getItem();

    fd.setName(uploadField.getFileName());
    fd.setCreateDate(timeSource.currentTimestamp());
    fd.setExtension(FilenameUtils.getExtension(uploadField.getFileName()));

    FileUploadingAPI fileUploading = AppBeans.get(FileUploadingAPI.NAME);
    File file = fileUploading.getFile(uploadField.getFileId());

    fd.setSize(file.length());

    okBtn.setEnabled(true);

    nameField.requestFocus();

    needSave = true;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:20,代碼來源:FileEditor.java


注:本文中的com.haulmont.cuba.core.entity.FileDescriptor.setSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。