당신이 Google 클라우드 스토리지에 업로드 할 사진들이 URL을 작성하도록 요청 이유 GCS에 BLOB으로 저장 것으로 보인다. 문서 [1]에 따라 Python에서 Blobstore API와 관련이 있지만 BLOB의 개념은 모든 언어에서 동일하므로 BLOB에 대해 읽는 것이 좋습니다. 또한 GCS에 사진을 업로드하는 데 도움이 될 샘플 코드를 아래에서 찾으십시오.
$options = [ 'gs_bucket_name' => 'bucket-name' ];
$upload_url = CloudStorageTools::createUploadUrl('/upload', $options);
<form action="<?php echo $upload_url?>" method="post" enctype="multipart/form-data">
<input type ="file" name="fileupload" id = "fileupload">
<input type="submit" value="Upload" name ="submit">
</form>
Upload Handler:
<?php
use google\appengine\api\cloud_storage\CloudStorageTools;
$gs_name = $_FILES['fileupload'];
$buffer = file_get_contents($gs_name['tmp_name']);
$bucket = CloudStorageTools::getDefaultGoogleStorageBucketName();
$user_pic_url = 'gs://' . $bucket
. (substr($final_file_path,0,1) != '/' ? '/' : '')
. $final_file_path;
// set file options on Google Could Storage
$options = stream_context_create(['gs' => ['acl' => 'public-read',
'Content-Type' => 'image/jpg']]);
echo "<br>";
$my_file = fopen($user_pic_url, 'w', false, $options);
fclose($my_file);
[1] Blob 저장소 API :https://cloud.google.com/appengine/docs/python/blobstore/