Last active
March 2, 2020 00:03
-
-
Save edutrul/b9cf47337ab628b75016db9bd96245dc to your computer and use it in GitHub Desktop.
Convert image byte array json object to download it into a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://example.com/api/v1/file?id=8972893948981 | |
// Displays the following json object: | |
// {"asset":{"file":{"data":[-119,80,78,71,13,10,26,10,0,0,0,13,73,,,,, etc | |
// Here's the php cone snippet to display to image in the browser. | |
$result = json_decode(file_get_contents($full_url)); | |
$raw_file = implode(array_map('chr', $result->asset->file->data)); | |
$file_path = $result->asset->file->path; | |
file_put_contents($file_path, $raw_file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment