Hello.

I am using Amazon s3 for file storage, so the uri of my files are saved in Drupal with the schema api-storage://...

When I want to show these files I use the function file_create_url and then I get a valid url, but its schema is always http and I need the returned url is https instead http.
Do you know if there is a way to get the transformed url from a uri with the schema 'storage-api' with https?

Example:

$url = file_create_url('storage-api://image.jpg')
//$url is http://bucket_name.s3.amazonaws.com/image.jpg

I don't know how to get the file url with htpps. If I have to set any flag that i didn't see or if I have to use another function than file_create_url to get the url with https.

Many thanks in advance for your help!

Paco.

Comments

Jaypan’s picture

$http_url = file_create_url('storage-api://image.jpg');
$https_url = str_replace('http://', 'https://', $http_url);
DrWaksman’s picture

Thanks jaypan.

I hoped there was a different way to get the url than just the string replace.

Thanks for your answer :)