Snap icon indicating copy to clipboard operation
Snap copied to clipboard

[FeatureRequest]Could we have a primitive to return binary data from a URL

Open cymplecy opened this issue 2 years ago • 8 comments

Just being cheeky but if you don't ask, you don't get :)

I needed to access the binary data returned from a URL request and modified your Snap! code to get it

ff2832b0617355ddc277283af5e09e04d3a46d93 (1)

Would there be some chance of getting this (but properly coded of course) as a primitive or adding it as some sort of option to to the existing one?

cymplecy avatar Jan 28 '23 14:01 cymplecy

nope, sorry, not as a general purpose primitive for the impending v8.1 release. Why don't you add it to your MQTT extension?

jmoenig avatar Jan 29 '23 09:01 jmoenig

Its not an MQTT thing so I wouldn't want to pollute the library :)

cymplecy avatar Jan 29 '23 10:01 cymplecy

Did you see the new text to utf8 and text from utf8 extension primitives? Don't those already do what you want?

jmoenig avatar Jan 29 '23 11:01 jmoenig

Unfortunately not AFAICT - the standard URL block has already returned the data as UTF-16 (I think) so the data is already "corrupted" and the txt->utf8 isn't able to decode it correctly

The real binary returned by my JS is

TTS_textToSpeech_sound script pic (9)

The data returned by the standard URL reporter is TTS_textToSpeech_sound script pic (10)

And AFAICT the txt->utf8 cannot recover the values at items 5,26 and 29 TTS_textToSpeech_sound script pic (11)

cymplecy avatar Jan 29 '23 12:01 cymplecy

I think a tool like this makes sense in the web services library personally. It would be useful - and I don’t remember if we’ve ever added a way to nicely grab images and sounds. -- Michael BallFrom my iPhonemichaelball.coOn Jan 29, 2023, at 4:26 AM, Simon Walters @.***> wrote: Unfortunately not AFAIC - the standard URL block has already returned the data as UTF-16 (I think) so the data is already "corrupted" and the txt->utf8 isn't able to decode it correctly The real binary returned by the my JS is

The data returned by the standard URL reporter is

And AFAICT the txt->utf8 cannot recover the values at items 5,26 and 29

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

cycomachead avatar Jan 29 '23 22:01 cycomachead

yeah, the web services library would probably be a reasonable place to put this. We do have an extension primitive for importing a costume from a url since last summer, btw.

jmoenig avatar Jan 30 '23 07:01 jmoenig

Just re-raising this (given all the discussion about importing large amounts of data)

cymplecy avatar Feb 27 '23 10:02 cymplecy

Coming in one of the next patches, I've already implemented it for the upcoming AstroSnap! extension.

jmoenig avatar Dec 07 '23 16:12 jmoenig