jquery - 在 Linux 网络系统上存档时如何在 ReactJs 中显示图像?[ReactJs/GraphQl]
问题描述
我正在使用 ReactJs 和 GraphQl 将 FORMS 系统转换为 Web,碰巧在要转换的屏幕之一中必须显示/插入图像,问题是正在显示的图像位于网络 Linux 服务器和路径上不返回任何东西。*项目文件夹位于不同的服务器和 Windows 上。
我试图依赖另一个代码,该代码来自不再参与项目的开发人员,用于从该 Linux 服务器 JasperUtil.java 获取报告:
/***
* Returns path relative to sub-directory within the network files / systems folder.
*
* @param parametersMap
* @param subDir
* @param relativeFile
* @return Relative path or null if not a path within the files subdirectory hierarchy/subDir.
*/
public static File getArquivo(Map<String, Object> parametersMap, String subDir, String relativeFile)
{
if (relativeFile == null)
return null;
File dir = new File((String) parametersMap.get("ARQUIVOS_DIR"), subDir);
File file = new File(dir, relativeFile.replace('\\', '/'));
if (!FileUtil.isSubPath(dir, file))
throw new RuntimeException(String.format("Arquivo %s não é filho de %s.", file, dir));
return file;
}
}
如何在 Linux 网络系统上存档的 ReactJs 中显示图像?我对这种情况一无所知,我在互联网上搜索了几种方法,但找不到类似的东西。在其他在项目中查找图像/附件的屏幕中,我们使用以下方式:
后端,示例 processo-exemlo-anexo.yml
types:
ProcessoExemploAnexo:
parameters:
- name: codigos
type: Integer[]
batchField: codigo
- name: proexeCodigos
type: Integer[]
batchField: proexeCodigo
- name: tipo
type: String
- name: where
type: String
expression: |
concatSql(
andInList("projudane.codigo", $P{codigos}),
andInList("projudane.proexe_codigo", $P{projudCodigos}),
$P{tipo}.mapNonAbsent("and proexeane.tipo = $$P{tipo}").orElse("")
)
query: |
select proexeane.codigo,
proexeane.caminho_arquivo nome,
proexeane.proexe_codigo "proexeCodigo"
from processo_exemplo_anexo proexeane
where 1 = 1
$P!{where}
queryFields:
codigo:
type: Integer
nome:
type: String
proxeCodigo:
type: Integer
internal: true
inputTypes:
ProcessoExemploAnexoInput:
fields:
codigo:
type: Integer
nome:
type: String
fileUpload:
type: FileUpload
FileUpload:
javaType: mm.api.model.sis.FileUpload
fields:
id:
type: String
contentType:
type: String
fileSize:
type: Long
submittedFileName:
type: String
interface AnexosProps {
model: RecordType;
}
const Anexos = namedObserver('Anexos', (props: AnexosProps) => {
const deleteAnexo = action((index: number) => {
const anexo = props.model.processosExemplosAnexos[index];
if (anexo.codigo) {
if (!props.model.anexosDelete)
props.model.anexosDelete = [];
props.model.anexosDelete.push(anexo.codigo)
}
props.model.processosExemplosAnexos.splice(index, 1);
});
const insertAnexos = action((fileList: FileList) => {
Array.from(fileList).forEach(file => props.model.processosExemplosAnexos.push({
codigo: null,
nome: file.name,
fileUpload: file
}));
});
return (
<React.Fragment>
{props.model.processosExemplosAnexos.map((anexo: typeof props.model.processosExemplosAnexos[number], index) =>
<p key={index} style={{ lineHeight: '1.5em' }}>
<a href={anexo.url}>{anexo.nome}</a>
{props.model.status == 'P' &&
<span
className='fa fa-trash-alt'
style={{ cursor: 'pointer', marginLeft: '0.7em' }}
title='Excluir'
onClick={() => deleteAnexo(index)}
/>
}
</p>
)}
<br />
<UploadButton
style={props.model.processosExemplosAnexos?.length > 0 ? { marginTop: '1em' } : undefined}
disabled={props.model.status != 'P' }
multiple
onSelected={insertAnexos}
>
Adicionar Imagem
</UploadButton>
</React.Fragment>
);
});
解决方案
推荐阅读
- jquery - 如何对使用 Jquery 的 Angular 6 组件进行单元测试
- postgresql - 在多边形中查找点
- if-statement - 比较两列 VLOOKUP 或 IF 时如何填充值?
- javascript - Bootstrap 下拉子菜单关闭上游子菜单
- docker - 使用 docker 映像作为依赖项,我想在 docker compose 中运行多个命令但无法执行
- r - 如何将 JSON 文件转换为 R 中的数据框?
- javascript - Dragend 客户端在 Safari 和 Firefox 上的坐标不一致
- sql - SQL 日期智能:从最后一个已知有效结果开始按秒过滤数据
- java - 是否有使用 ImageIcon 和 URL 下载图像的异步方式?
- php - PHP 错误提示:尝试在第 303 行获取 C:\code 中非对象的属性