简体   繁体   English

如何在ngrx store Angular中保存FileList?

[英]How to save FileList in ngrx store Angular?

I am trying to save FileList in ngrx store, but when I try to store it then in redux developer tools it shows:我正在尝试将 FileList 保存在 ngrx 商店中,但是当我尝试将其存储在 redux 开发人员工具中时,它显示:

 files: {0: {}}

But when I do console.log then I am passing this data to save in the store:但是当我执行 console.log 时,我将传递这些数据以保存在商店中:

 FileList {0: File, length: 1} 0: File lastModified: 1658383941089 lastModifiedDate: Thu Jul 21 2022 08:12:21 GMT+0200 (Ora legale dell'Europa centrale) {} name: "milan-to-sestSanGiovanni.jpeg" size: 2865736 type: "image/jpeg" webkitRelativePath: "" [[Prototype]]: File length: 1 [[Prototype]]: FileList

I would like to know is it possible to store FileList/File in the ngrx store?我想知道是否可以将 FileList/File 存储在 ngrx 存储中? If it is possible then how can be it done.如果有可能,那怎么做。 Thank you谢谢

This is because the redux developer tools show the JSON version of the objects.这是因为 redux 开发人员工具显示对象的 JSON 版本。 A filelist cannot be serialized (you can test this with JSON.stringify(files) ).无法序列化文件列表(您可以使用JSON.stringify(files)进行测试)。

Depending on the configured runtime checks the object can be saved to the store (the state and action need to contain serializable state).根据配置的运行时检查,object 可以保存到存储中(state 和操作需要包含可序列化状态)。 This can be turned off, this has as result that the object will be persisted in the store, but the redux devtools won't be able to display it correctly.这可以关闭,这会导致 object 将保留在商店中,但 redux 开发工具将无法正确显示它。

https://ngrx.io/guide/store/configuration/runtime-checks https://ngrx.io/guide/store/configuration/runtime-checks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM