uploading image to google cloud storage from compute engine instance












0















I need your help with uploading an image file from google compute engine instance to google cloud storage.
I have been able to move an image from a frontend form with php with the usual move_uploaded_file function but the real problem surfaces when I Try to copy that file to google cloud storage within php script using gsutil command.
After quick debugging I found these results



**Tue Jan 01 04:45:12.491702 2019] [core:notice] [pid 8539] AH00094: Command line: '/usr/sbin/apache2'
sh: 1: /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found
sh: 1: /var/www/includes/unloadUploads.sh/var/www/html/uploads/markii.jpg: not found
baraka_ben@igroup1us-xszd:/var/log/apache2$ cd /var/www/html/uploads/
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls
markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls -lh
total 4.0K
-rw-r--r-- 1 www-data www-data 3.0K Jan 1 04:50 markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$**


But again, if I try the same command within the shell console ssh environment it runs smoothly without any problem as shown hereunder



baraka_ben@igroup1us-xszd:/var/www/html/uploads$ gsutil cp markii.jpg gs://bucket/Folder/SubFolder
Copying file://markii.jpg [Content-Type=image/jpeg]...
/ [1 files][ 2.9 KiB/ 2.9 KiB]
Operation completed over 1 objects/2.9 KiB.
baraka_ben@igroup1us-xszd:/var/www/html/uploads$


nota bene the bucket name shown here is not the actual one and the multimediaStorage.sh script contains similar command syntax to what the above code has.
Now I am stranded as I Tried to figure out the folder and file ownership and permissions rights by making the "www-data" user the owner of the folder /var/www/html/uploads but it does not seem to be of any help.
May you please help me to get over this hurdle.
Down here is my php script part related to this question



if (!empty($_FILES['picha']) && $_FILES['picha']['error'] == UPLOAD_ERR_OK) {
$tmpName = $_FILES['picha']['tmp_name'];
$name = basename($_FILES['picha']['name']);
$desnation="/var/www/html/uploads/$name";

$message=move_uploaded_file($tmpName,$desnation);
$repository=$desnation;
$destiny="gs://BucketName/Folder/Subfolder/";
$execution="/var/www/includes/multimediaStorage.sh";
$destination ='gs:BucketName/Folder/Subfolder/'."$name";
$combination="$repository $destiny";
exec($execution.''.$combination);
$clearence="/var/www/includes/unloadUploads.sh";
array_push($Patharray,$destination);
// unlink("/var/www/html/uploads/$filename");
exec($clearence.''.$repository);
}


Happy New Year 2019 and THANKS IN ADVANCE!










share|improve this question

























  • From what I see in your debug output, for example, /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found. It is complaining for the unavailable path. So, it looks like a syntax error in your code. Please add a space string between $execution and $combination. The delimiter I see in the first exec command is just an empty string. If my guess is right, this question doesn't belong to GCP category.

    – mehdi sharifi
    Jan 2 at 3:53













  • thanks Mehdi! after amending the code I got the following:ERROR: (gsutil) Failed to create the default configuration. Ensure your have the correct permissions on: [/var/www/ .config/gcloud/configurations]. Could not create directory [/var/www/.config/gcloud/configurations]: Permission denied. Please verify that you have permissions to write to the parent directory.

    – Benedict
    Jan 2 at 9:18













  • from the observations above I think there is relevance to the gcp category even though not very much directly

    – Benedict
    Jan 2 at 9:21











  • From your comment, it looks like the "not found" error is resolved. The new issue might be caused by the permissions associated to your user account by which you run gsutil commands on the instance. Please review this related story on using "chown USER -R DIRECTORY" to resolve it.

    – mehdi sharifi
    Jan 8 at 22:36
















0















I need your help with uploading an image file from google compute engine instance to google cloud storage.
I have been able to move an image from a frontend form with php with the usual move_uploaded_file function but the real problem surfaces when I Try to copy that file to google cloud storage within php script using gsutil command.
After quick debugging I found these results



**Tue Jan 01 04:45:12.491702 2019] [core:notice] [pid 8539] AH00094: Command line: '/usr/sbin/apache2'
sh: 1: /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found
sh: 1: /var/www/includes/unloadUploads.sh/var/www/html/uploads/markii.jpg: not found
baraka_ben@igroup1us-xszd:/var/log/apache2$ cd /var/www/html/uploads/
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls
markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls -lh
total 4.0K
-rw-r--r-- 1 www-data www-data 3.0K Jan 1 04:50 markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$**


But again, if I try the same command within the shell console ssh environment it runs smoothly without any problem as shown hereunder



baraka_ben@igroup1us-xszd:/var/www/html/uploads$ gsutil cp markii.jpg gs://bucket/Folder/SubFolder
Copying file://markii.jpg [Content-Type=image/jpeg]...
/ [1 files][ 2.9 KiB/ 2.9 KiB]
Operation completed over 1 objects/2.9 KiB.
baraka_ben@igroup1us-xszd:/var/www/html/uploads$


nota bene the bucket name shown here is not the actual one and the multimediaStorage.sh script contains similar command syntax to what the above code has.
Now I am stranded as I Tried to figure out the folder and file ownership and permissions rights by making the "www-data" user the owner of the folder /var/www/html/uploads but it does not seem to be of any help.
May you please help me to get over this hurdle.
Down here is my php script part related to this question



if (!empty($_FILES['picha']) && $_FILES['picha']['error'] == UPLOAD_ERR_OK) {
$tmpName = $_FILES['picha']['tmp_name'];
$name = basename($_FILES['picha']['name']);
$desnation="/var/www/html/uploads/$name";

$message=move_uploaded_file($tmpName,$desnation);
$repository=$desnation;
$destiny="gs://BucketName/Folder/Subfolder/";
$execution="/var/www/includes/multimediaStorage.sh";
$destination ='gs:BucketName/Folder/Subfolder/'."$name";
$combination="$repository $destiny";
exec($execution.''.$combination);
$clearence="/var/www/includes/unloadUploads.sh";
array_push($Patharray,$destination);
// unlink("/var/www/html/uploads/$filename");
exec($clearence.''.$repository);
}


Happy New Year 2019 and THANKS IN ADVANCE!










share|improve this question

























  • From what I see in your debug output, for example, /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found. It is complaining for the unavailable path. So, it looks like a syntax error in your code. Please add a space string between $execution and $combination. The delimiter I see in the first exec command is just an empty string. If my guess is right, this question doesn't belong to GCP category.

    – mehdi sharifi
    Jan 2 at 3:53













  • thanks Mehdi! after amending the code I got the following:ERROR: (gsutil) Failed to create the default configuration. Ensure your have the correct permissions on: [/var/www/ .config/gcloud/configurations]. Could not create directory [/var/www/.config/gcloud/configurations]: Permission denied. Please verify that you have permissions to write to the parent directory.

    – Benedict
    Jan 2 at 9:18













  • from the observations above I think there is relevance to the gcp category even though not very much directly

    – Benedict
    Jan 2 at 9:21











  • From your comment, it looks like the "not found" error is resolved. The new issue might be caused by the permissions associated to your user account by which you run gsutil commands on the instance. Please review this related story on using "chown USER -R DIRECTORY" to resolve it.

    – mehdi sharifi
    Jan 8 at 22:36














0












0








0


1






I need your help with uploading an image file from google compute engine instance to google cloud storage.
I have been able to move an image from a frontend form with php with the usual move_uploaded_file function but the real problem surfaces when I Try to copy that file to google cloud storage within php script using gsutil command.
After quick debugging I found these results



**Tue Jan 01 04:45:12.491702 2019] [core:notice] [pid 8539] AH00094: Command line: '/usr/sbin/apache2'
sh: 1: /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found
sh: 1: /var/www/includes/unloadUploads.sh/var/www/html/uploads/markii.jpg: not found
baraka_ben@igroup1us-xszd:/var/log/apache2$ cd /var/www/html/uploads/
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls
markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls -lh
total 4.0K
-rw-r--r-- 1 www-data www-data 3.0K Jan 1 04:50 markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$**


But again, if I try the same command within the shell console ssh environment it runs smoothly without any problem as shown hereunder



baraka_ben@igroup1us-xszd:/var/www/html/uploads$ gsutil cp markii.jpg gs://bucket/Folder/SubFolder
Copying file://markii.jpg [Content-Type=image/jpeg]...
/ [1 files][ 2.9 KiB/ 2.9 KiB]
Operation completed over 1 objects/2.9 KiB.
baraka_ben@igroup1us-xszd:/var/www/html/uploads$


nota bene the bucket name shown here is not the actual one and the multimediaStorage.sh script contains similar command syntax to what the above code has.
Now I am stranded as I Tried to figure out the folder and file ownership and permissions rights by making the "www-data" user the owner of the folder /var/www/html/uploads but it does not seem to be of any help.
May you please help me to get over this hurdle.
Down here is my php script part related to this question



if (!empty($_FILES['picha']) && $_FILES['picha']['error'] == UPLOAD_ERR_OK) {
$tmpName = $_FILES['picha']['tmp_name'];
$name = basename($_FILES['picha']['name']);
$desnation="/var/www/html/uploads/$name";

$message=move_uploaded_file($tmpName,$desnation);
$repository=$desnation;
$destiny="gs://BucketName/Folder/Subfolder/";
$execution="/var/www/includes/multimediaStorage.sh";
$destination ='gs:BucketName/Folder/Subfolder/'."$name";
$combination="$repository $destiny";
exec($execution.''.$combination);
$clearence="/var/www/includes/unloadUploads.sh";
array_push($Patharray,$destination);
// unlink("/var/www/html/uploads/$filename");
exec($clearence.''.$repository);
}


Happy New Year 2019 and THANKS IN ADVANCE!










share|improve this question
















I need your help with uploading an image file from google compute engine instance to google cloud storage.
I have been able to move an image from a frontend form with php with the usual move_uploaded_file function but the real problem surfaces when I Try to copy that file to google cloud storage within php script using gsutil command.
After quick debugging I found these results



**Tue Jan 01 04:45:12.491702 2019] [core:notice] [pid 8539] AH00094: Command line: '/usr/sbin/apache2'
sh: 1: /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found
sh: 1: /var/www/includes/unloadUploads.sh/var/www/html/uploads/markii.jpg: not found
baraka_ben@igroup1us-xszd:/var/log/apache2$ cd /var/www/html/uploads/
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls
markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls -lh
total 4.0K
-rw-r--r-- 1 www-data www-data 3.0K Jan 1 04:50 markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$**


But again, if I try the same command within the shell console ssh environment it runs smoothly without any problem as shown hereunder



baraka_ben@igroup1us-xszd:/var/www/html/uploads$ gsutil cp markii.jpg gs://bucket/Folder/SubFolder
Copying file://markii.jpg [Content-Type=image/jpeg]...
/ [1 files][ 2.9 KiB/ 2.9 KiB]
Operation completed over 1 objects/2.9 KiB.
baraka_ben@igroup1us-xszd:/var/www/html/uploads$


nota bene the bucket name shown here is not the actual one and the multimediaStorage.sh script contains similar command syntax to what the above code has.
Now I am stranded as I Tried to figure out the folder and file ownership and permissions rights by making the "www-data" user the owner of the folder /var/www/html/uploads but it does not seem to be of any help.
May you please help me to get over this hurdle.
Down here is my php script part related to this question



if (!empty($_FILES['picha']) && $_FILES['picha']['error'] == UPLOAD_ERR_OK) {
$tmpName = $_FILES['picha']['tmp_name'];
$name = basename($_FILES['picha']['name']);
$desnation="/var/www/html/uploads/$name";

$message=move_uploaded_file($tmpName,$desnation);
$repository=$desnation;
$destiny="gs://BucketName/Folder/Subfolder/";
$execution="/var/www/includes/multimediaStorage.sh";
$destination ='gs:BucketName/Folder/Subfolder/'."$name";
$combination="$repository $destiny";
exec($execution.''.$combination);
$clearence="/var/www/includes/unloadUploads.sh";
array_push($Patharray,$destination);
// unlink("/var/www/html/uploads/$filename");
exec($clearence.''.$repository);
}


Happy New Year 2019 and THANKS IN ADVANCE!







php bash google-cloud-storage google-compute-engine






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 18:41







Benedict

















asked Jan 1 at 6:05









BenedictBenedict

14




14













  • From what I see in your debug output, for example, /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found. It is complaining for the unavailable path. So, it looks like a syntax error in your code. Please add a space string between $execution and $combination. The delimiter I see in the first exec command is just an empty string. If my guess is right, this question doesn't belong to GCP category.

    – mehdi sharifi
    Jan 2 at 3:53













  • thanks Mehdi! after amending the code I got the following:ERROR: (gsutil) Failed to create the default configuration. Ensure your have the correct permissions on: [/var/www/ .config/gcloud/configurations]. Could not create directory [/var/www/.config/gcloud/configurations]: Permission denied. Please verify that you have permissions to write to the parent directory.

    – Benedict
    Jan 2 at 9:18













  • from the observations above I think there is relevance to the gcp category even though not very much directly

    – Benedict
    Jan 2 at 9:21











  • From your comment, it looks like the "not found" error is resolved. The new issue might be caused by the permissions associated to your user account by which you run gsutil commands on the instance. Please review this related story on using "chown USER -R DIRECTORY" to resolve it.

    – mehdi sharifi
    Jan 8 at 22:36



















  • From what I see in your debug output, for example, /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found. It is complaining for the unavailable path. So, it looks like a syntax error in your code. Please add a space string between $execution and $combination. The delimiter I see in the first exec command is just an empty string. If my guess is right, this question doesn't belong to GCP category.

    – mehdi sharifi
    Jan 2 at 3:53













  • thanks Mehdi! after amending the code I got the following:ERROR: (gsutil) Failed to create the default configuration. Ensure your have the correct permissions on: [/var/www/ .config/gcloud/configurations]. Could not create directory [/var/www/.config/gcloud/configurations]: Permission denied. Please verify that you have permissions to write to the parent directory.

    – Benedict
    Jan 2 at 9:18













  • from the observations above I think there is relevance to the gcp category even though not very much directly

    – Benedict
    Jan 2 at 9:21











  • From your comment, it looks like the "not found" error is resolved. The new issue might be caused by the permissions associated to your user account by which you run gsutil commands on the instance. Please review this related story on using "chown USER -R DIRECTORY" to resolve it.

    – mehdi sharifi
    Jan 8 at 22:36

















From what I see in your debug output, for example, /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found. It is complaining for the unavailable path. So, it looks like a syntax error in your code. Please add a space string between $execution and $combination. The delimiter I see in the first exec command is just an empty string. If my guess is right, this question doesn't belong to GCP category.

– mehdi sharifi
Jan 2 at 3:53







From what I see in your debug output, for example, /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found. It is complaining for the unavailable path. So, it looks like a syntax error in your code. Please add a space string between $execution and $combination. The delimiter I see in the first exec command is just an empty string. If my guess is right, this question doesn't belong to GCP category.

– mehdi sharifi
Jan 2 at 3:53















thanks Mehdi! after amending the code I got the following:ERROR: (gsutil) Failed to create the default configuration. Ensure your have the correct permissions on: [/var/www/ .config/gcloud/configurations]. Could not create directory [/var/www/.config/gcloud/configurations]: Permission denied. Please verify that you have permissions to write to the parent directory.

– Benedict
Jan 2 at 9:18







thanks Mehdi! after amending the code I got the following:ERROR: (gsutil) Failed to create the default configuration. Ensure your have the correct permissions on: [/var/www/ .config/gcloud/configurations]. Could not create directory [/var/www/.config/gcloud/configurations]: Permission denied. Please verify that you have permissions to write to the parent directory.

– Benedict
Jan 2 at 9:18















from the observations above I think there is relevance to the gcp category even though not very much directly

– Benedict
Jan 2 at 9:21





from the observations above I think there is relevance to the gcp category even though not very much directly

– Benedict
Jan 2 at 9:21













From your comment, it looks like the "not found" error is resolved. The new issue might be caused by the permissions associated to your user account by which you run gsutil commands on the instance. Please review this related story on using "chown USER -R DIRECTORY" to resolve it.

– mehdi sharifi
Jan 8 at 22:36





From your comment, it looks like the "not found" error is resolved. The new issue might be caused by the permissions associated to your user account by which you run gsutil commands on the instance. Please review this related story on using "chown USER -R DIRECTORY" to resolve it.

– mehdi sharifi
Jan 8 at 22:36












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993359%2fuploading-image-to-google-cloud-storage-from-compute-engine-instance%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993359%2fuploading-image-to-google-cloud-storage-from-compute-engine-instance%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$