Here's something fun. Our system includes a file manager for our users. The files are being stored in a bucket in Google Cloud Storage. What I need to do is create a "folder" in the bucket. Yes, I know that GCS is a flat space, and folders aren't really a thing... but I can go to the Google Cloud Platform browser and click on a button called "CREATE FOLDER", and it creates something that looks just like a folder. There shouldn't be any content to it. I am trying to use cURL to write something the storage object so that it is "saved":
$bucket = $google_client( $bucket_name );
$folder = $bucket->object( $folder_name );
$url = $folder->beginSignedUploadSession();
// now we have to make an HTTP "PUT"
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_PUT, 1);
curl_setopt($ch,CURLOPT_INFILE, ""); <--- this is wrong
curl_setopt($ch,CURLOPT_INFILESIZE, 0);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Or should I just create dummy "file" to append to the URL I'm creating with a dummy value in it?
I suppose I should add that I am working with an existing system that does this using an older version of the GCS API, using code like:
$postbody = [ 'data' => $data ,
'uploadType' => "multipart",
'mimeType' => 'text/plain'];
$gso = new Google_Service_Storage_StorageObject();
$gso->setName( $foldername );
$resp = $objects->insert( $bucket, $gso, $postbody );