updated bucket path

parent f82bcb06
Showing with 2 additions and 2 deletions
......@@ -10,12 +10,12 @@ function upload_to_bucket ($bucket_name, $path) {
// Authentication with Google Cloud Platform
$storage = new StorageClient();
$bucket = $storage->bucket($bucket_name . '/' . $path);
$bucket = $storage->bucket($bucket_name);
// Upload a file to the bucket.
$file = pathinfo($_FILES['file']['name']);
$prefix = uniqid('uploaded_', true); //generate random string to avoid name conflicts
$filename = $prefix . "." . $file['extension'];
$filename = $path . '/' . $prefix . "." . $file['extension'];
$bucket->upload(
fopen($_FILES['file']['tmp_name'], 'r'),
['name' => $filename]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment