本文整理汇总了Java中com.haulmont.cuba.core.entity.FileDescriptor.getId方法的典型用法代码示例。如果您正苦于以下问题:Java FileDescriptor.getId方法的具体用法?Java FileDescriptor.getId怎么用?Java FileDescriptor.getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.haulmont.cuba.core.entity.FileDescriptor
的用法示例。
在下文中一共展示了FileDescriptor.getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFileInfoResponseEntity
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
protected ResponseEntity<FileInfo> createFileInfoResponseEntity(HttpServletRequest request, FileDescriptor fd) {
FileInfo fileInfo = new FileInfo(fd.getId(), fd.getName(), fd.getSize());
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(request.getRequestURL().toString())
.path("/{id}")
.buildAndExpand(fd.getId().toString());
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(uriComponents.toUri());
return new ResponseEntity<>(fileInfo, httpHeaders, HttpStatus.CREATED);
}
示例2: uploadToMiddleware
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
protected void uploadToMiddleware(InputStream is, FileDescriptor fd) throws FileStorageException {
try {
fileLoader.saveStream(fd, new FileLoader.SingleInputStreamSupplier(is));
} catch (FileStorageException e) {
throw new RestAPIException("Unable to upload file to FileStorage",
"Unable to upload file to FileStorage: " + fd.getId(),
HttpStatus.INTERNAL_SERVER_ERROR);
}
}
示例3: downloadFromMiddlewareAndWriteResponse
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
protected void downloadFromMiddlewareAndWriteResponse(FileDescriptor fd, HttpServletResponse response) throws IOException {
ServletOutputStream os = response.getOutputStream();
try (InputStream is = fileLoader.openStream(fd)) {
IOUtils.copy(is, os);
os.flush();
} catch (FileStorageException e) {
throw new RestAPIException("Unable to download file from FileStorage",
"Unable to download file from FileStorage: " + fd.getId(),
HttpStatus.INTERNAL_SERVER_ERROR);
}
}