本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}