Using JsEvent("GetFileContents") for large files
Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
mkhtran
9 - Comet
09-28-2023
04:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It seems that `JsEvent("GetFileContents")` will fail (return an empty string) if it tries to read a file that is too big. Somewhere around 1 MB is the limit.
Is there any way around this?
Currently I have to chunk my data across multiple files so that the UI can read it with `JsEvent("GetFileContents")`.
def on_complete(self) -> None:
chunk_size = 1000000 # This is a good size to prevent GetFileContents from failing
for index in range(0, len(self.data), chunk_size):
chunk = data[index:index + chunk_size]
with open(self.provider.environment.create_temp_file(), "w") as data_file:
data_file.write(chunk)
void (async () => {
const chunks = []
for (const dataFile in dataFiles) {
chunks.push(await JsEvent('GetFileContents', { Path: dataFile }))
}
const data = chunks.join()
})()
But I also have other files I'd like to read that I cannot simply chunk.
Labels:
- Labels:
-
Custom Tools
-
HTML GUI
-
JavaScript
-
SDK
0 REPLIES 0