File Stream - Download in Chunks511
Pages:
1MikeMills private msg quote post Address this user | ||
Moved from another thread: @crevicedweller: File storage looks interesting. I tried it and it works well to download the file to a PC with essentially unlimited storage. I would like to use it with an embedded processor so would need to read the file a line at at time (maybe 512 bytes per transaction), save the line to local non-volatile storage, probably on an SD card, and keep repeating until the end of the file is encountered. This would provide the essential elements of an over the air upgrade capability to the embedded processor product. Is there a way to read the file as described? If not has that been considered as a future addition? |
||
Post 1 IP flag post |
MikeMills private msg quote post Address this user | ||
@crevicedweller Your suggestion makes sense in the device world. Eventually we will probably add streaming capabilities for video files, but I doubt that would help you. We could extend our API to do what you're asking. What would work for you? 1. Requesting by line number? 2. Requesting by startByteNumber and numberOfBytes |
||
Post 2 IP flag post |
crevicedweller private msg quote post Address this user | ||
The second method looks good, in part since it is similar to what I am used to with opening and reading a file directly. Pardon if this is redundant. For background, the file i posted is a binary image of the application code that runs on the embedded processor. I imagine a small protected portion of code on that processor that would read the file and program it into the normal run area on the processor then jump to that code for normal operation. The generic term for that is a "Bootloader" and is a common way to upgrade code on an embedded processor product. Placing the file on Grovestream, where we already have several streams monitoring normal operation solves several obstacles to the "over the air" upgrade process for a small company with limited ability to provide the servers etc to support access to the file. Probably what you meant by "...makes sense in the device world". |
||
Post 3 IP flag post |
MikeMills private msg quote post Address this user | ||
Would you be able to convert base64 encoded bytes if we return the bytes that way? Would it be a pain if we include the base64 as part of a JSON response:
Or is life easier if we just return the base64 string only? alskdjfal |
||
Post 4 IP flag post |
crevicedweller private msg quote post Address this user | ||
Base64 is OK, I prefer the string only but could work with the JSON response also. | ||
Post 5 IP flag post |
MikeMills private msg quote post Address this user | ||
Implemented. See start and limit parameters in the API here: https://www.grovestreams.com/developers/api.html#7 Decided not to return JSON. Easier to handle in embed code. Note that in the API, each chunk can contain padding as per base64 specs. So, you will want to decode each chunk as it's returned. Here's some Java code we used to test it:
|
||
Post 6 IP flag post |
crevicedweller private msg quote post Address this user | ||
This looks great. Thanks Mike. I am away from the office until Wednesday but will try this out as soon as i am back. |
||
Post 7 IP flag post |
crevicedweller private msg quote post Address this user | ||
I now have demo version of code running on my target hardware that reads chunks from the file i posted. Looks like exactly what we need! | ||
Post 8 IP flag post |
crevicedweller private msg quote post Address this user | ||
cancelled post | ||
Post 9 IP flag post |
crevicedweller private msg quote post Address this user | ||
Cancelled post | ||
Post 10 IP flag post |
Pages:
1