examples
examples copied to clipboard
Add Compress Image for Ruby
Closes: https://github.com/appwrite/appwrite/issues/4123
I use this python script below to test the api call,
import requests
import json
url = "http://localhost:3000"
provider = "krakenio"
image = "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAs...wIKAMAOCkkTBNfnUoAAAAASUVORK5CYII="
headers = {
"X-Internal-Challenge": "secret-key",
"Content-Type": "application/json"
}
payload = {"provider": provider, "image": image}
variables = {
"TINYPNG_API": "ng...9",
"KRAKENIO_KEY": "24...3",
"KRAKENIO_SECRET": "dc...1"
}
data = {"payload": json.dumps(payload), "env": variables}
r = requests.post(url = url, headers = headers, json=data)
print(r)
print(r.json())
which then produce this result,
{
'success': True,
'image': 'iVBORw0KGgoAAAANSUhEUgAAAAQAAAAGCAIAAABrW6giAAAAMUlEQVQYGQXB\nAQ2AAAzAsO25f1MEG0j5aH2frw4YZ6mqwNtAVYGpQOjuBohUdQEiUn+73Bpx\nfmGEqAAAAABJRU5ErkJggg==\n'
}
This works for both tinypng and krakenio for supposedly any .png files
Thank you so much for the PR 🤩. We're adding the hacktoberfest-accepted label to ensure this PR counts towards your Hacktoberfest contributions count. With that said, please stay active on this PR to address any comments once you receive a review. Happy Hacktoberfest! 🎃
Changed according to the comments, and also add a simple tester in python. Not sure if it will be helpful or not.
All requests fixed and committed.
Thanks for the amazing PR 😇 I have added small changes documentation. Merging the PR now 🥳