Saturday, December 9, 2017

Availability of a file / link publically on Google Cloud Storage

If you want to check if a file exists publically on Google Cloud Storage,

PHP
<?php
$flyer = "http://commondatastorage.googleapis.com/bucket/path/to/directory/image.jpg";
$headers = @get_headers($flyer);
if ($headers[0] != "HTTP/1.1 200 OK" && $headers[0] != "HTTP/1.0 200 OK")
{
    # Load file locally / from elsewhere
    $flyer = IMG."/image.jpg";
}?>
PHP 5

No comments:

Post a Comment