Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I GZIP a string?

Asked by
GShocked 150
9 years ago

I have the following script; It basically collects the BrickColor Numbers of parts in a model, puts them into a table, converts them to JSON, and uploads them to Pastebin.

01ImgScript = {}
02for index, child in pairs(workspace.IMG:GetChildren()) do
03    table.insert(ImgScript, child.BrickColor.Number)
04end
05 
06h = game:GetService'HttpService'
07ImgScript = h:JSONEncode(ImgScript) --Convert to JSON
08 
09api_dev_key = 'MyPastebinAPIDeveloperKey'
10api_paste_code = ImgScript
11api_paste_private = '1'
12api_paste_name = 'TEST'
13api_paste_expire_date = 'N'
14api_paste_format = 'lua'
15api_user_key = ''
View all 32 lines...

This doesn't work for all uploads. It returns 'Bad API Request, invalid api_option' when I try this particular script.

This DOES work when the api_paste_code (the content of the paste) is something small like "Testing this api here". So I assume that this is because PostAsync data larger than 256 bytes has to be GZIPed before it is sent, afterward it can be up to 1024kb (1mb).

So how would I GZIP my data?

PS: I've also tried encoding it in base64 to make sure this problem isn't with spaces and symbols.

Answer this question