I have successfully installed Q2A on Google app engine platform with google cloud sql.
I would like site visitors to upload image files to their Questions and answers. I am using latest CKEditor4. The upload process on google app engine is bit different than Apache server/php.
As per my research the Google app engine does not allow file to be uploded to a temperory folder on the server. Insted image file has to be uploaded to the Google cloud storage and then Q2A can transfered it to the database as blob.
Following is the example code for creating the upload url on google cloud store.
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = [ 'gs_bucket_name' => 'my_bucket' ];
$upload_url = CloudStorageTools::createUploadUrl('/upload_handler.php', $options);
<form action="<?php echo $upload_url?>" enctype="multipart/form-data" method="post">
Files to upload: <br>
<input type="file" name="uploaded_files" size="40">
<input type="submit" value="Send">
</form>
After the file(s) upload, a POST is made to the path specified as the first parameter to createUploadUrl; in the example above, this is /upload_handler.php. The PHP runtime forms the correct $_FILES super global, and tmp_filename refers to the filename of the newly uploaded file in GCS.
----------------------------------------------------------------------------------------------------------------------------------------------------
Can anyone please explain how can I setup CKEditor temperory upload folder to the google cloud store and also update the $_Files. Once I get the $_files uploaded I think Q2A can transfer the files to the database.
----------------------------------------------------------------------------------------------------------------------------------------------------
Following is my investigation update:
By default ckeditor filebrowserImageUploadUrl action is set to the following:
http://appsiteid1.appspot.com/?qa=wysiwyg-editor-upload&qa_only_image=1&CKEditor=content&CKEditorFuncNum=0&langCode=en
As per the google cloud storage image upload procedure a $upload_url is created for 10 minutes using CloudStorageTools::createUploadUrl('/upload_handler.php', $options) (as explained above)
A typical file upload url to google cloud storage looks like below: NOtice the bold part starting from _ah is some type of authentication key for uploading files and can not be altered.
http://appsiteid1.appspot.com/_ah/upload/AMmfu6YUz1XXnV31GrKSXy1J2Kn7ROwZeV_8Mghp6CsedBdEQueMLjFTJleF-oQKp12GkzulVbBzd7A_trPH6LeSSIexGp4w4yYXn9lnRuOCF9LYtAvNVDPH6DALSOBz9RhzdPQdfsghdakdcPu3VDsppQ137ln-_JghR4g-kWlr3Tzs9mr6XVnKuXNTbjpJtnhWH_M6b74hJ3GtgUw19ZomC3yHVfQi40nA/ALBasasasAAAAUzBUJ6u-GMoPoHKYglKJektWJ2fTjO9y/
So to achieve this i changed the qa-ckeditor4.php file filebrowserImageUploadUrl parameters to the $upload_url. Then I get the following:
http://appsiteid1.appspot.com/_ah/upload/?qa=ask/AMmfu6a89jdywvv1cwTHs75Fs-MLMCHowSLH7VC1b3bnuTirZahZNLDnoPyMEg4bsynl_ryt7SnVchRtKKL1f_vGCJD6JtCiseT1mtQTaA_z5guUsLBdosw1kyeMHet5H-fdv1fcWeXVRMMRiPA4aL-n1zI3sOeSvDoU8y4-OA1ClREq04UClGl2H96ukKBRakBelIXr1Y4Q/ALBNUaYAAAAAUzBU-gyeYpivxebzGtPuYhMezt9qgqAg/&qa_only_image=1&CKEditor=content&CKEditorFuncNum=0&langCode=en
As mentioned the authentication key should not be altered, see parameters added in red. It gives me 500 server internal error bacause of mismatch.
Question is how can I remove the parameters highlighted in red and do the POST. After successful upload google app engine automatically creates $_FILES global variable with cloud storage raference. Here on Q2A can copy the data to blob table as usual.