use of com.haulmont.cuba.core.app.FileStorageService in project cuba by cuba-platform.
the class DesktopFileUploadField method getFileContent.
@Override
public InputStream getFileContent() {
if (contentProvider != null) {
return contentProvider.provide();
}
FileDescriptor fileDescriptor = getValue();
switch(mode) {
case MANUAL:
if (fileId == null) {
return new FileDataProvider(fileDescriptor).provide();
}
File file = fileUploading.getFile(fileId);
if (file != null) {
try {
return new FileInputStream(file);
} catch (FileNotFoundException e) {
log.error("Unable to get content of {}", file, e);
}
return null;
}
FileStorageService fileStorageService = AppBeans.get(FileStorageService.NAME);
try {
if (fileStorageService.fileExists(fileDescriptor)) {
return new FileDataProvider(fileDescriptor).provide();
}
} catch (FileStorageException e) {
log.error("Unable to get content of {}", fileDescriptor, e);
return null;
}
break;
case IMMEDIATE:
if (fileDescriptor != null) {
return new FileDataProvider(fileDescriptor).provide();
}
}
return null;
}
use of com.haulmont.cuba.core.app.FileStorageService in project cuba by cuba-platform.
the class WebFileUploadField method getFileContent.
@Override
public InputStream getFileContent() {
if (contentProvider != null) {
return contentProvider.provide();
}
FileDescriptor fileDescriptor = getValue();
switch(mode) {
case MANUAL:
if (fileId == null) {
return new FileDataProvider(fileDescriptor).provide();
}
File file = fileUploading.getFile(fileId);
if (file != null) {
try {
return new FileInputStream(file);
} catch (FileNotFoundException e) {
log.error("Unable to get content of {}", file, e);
}
return null;
}
FileStorageService fileStorageService = AppBeans.get(FileStorageService.NAME);
try {
if (fileStorageService.fileExists(fileDescriptor)) {
return new FileDataProvider(fileDescriptor).provide();
}
} catch (FileStorageException e) {
log.error("Unable to get content of {}", fileDescriptor, e);
return null;
}
break;
case IMMEDIATE:
if (fileDescriptor != null) {
return new FileDataProvider(fileDescriptor).provide();
}
}
return null;
}
Aggregations