I'm trying to link php files on Google cloud storage, but getting them as plain text. I want to connect to the other file but without App Engine, all the documentation of this is written exclusively for app engine and can't even find if bucket storage has php support even tho it should. Any clue of how to link a PHP file correctly on Cloud Storage?
Google cloud storage is storage service which can store your object(files) and return when you ask for it.Files like HTML,JavaScript and CSS that render inside browser can be placed on google cloud storage to get performance in loading time.But in your php file need execution engine to run it code.Placing them on storage and accessing will get to file context.
Related
I have project that needs to output hundreds of photos from one template file, compress them into a .zip file, and push them to the customer's browser. After that, the .zip file can be deleted.
Google App Engine (PHP) does not allow you to write files like you would in a standard web server.
How can this be accomplished with GAE flexible?
As you have already known, App Engine flexible does not allow you to write files on the system even if it runs on a VM. The reason is that it runs within more Docker containers and you will not have the guarantee that you will find the file.
An alternative for this is to change a bit your workflow and to use Cloud Storage as an intermediate. You can send the photos directly to Cloud Storage, and the users will be able to download them directly from Cloud Storage. Here you have a guide on how to achieve this from App Engine flex for PHP.
First, let me tell you what i'm trying to accomplish...maybe there's an easier way than using signed urls with google cloud storage:
i want to upload files without public access to my bucket and when someone navigates to my server (that's not a google compute engine instance, but a regular cpanel machine) it should display the files just fine.
One way of doing it is through an url on my server that would download the file from google storage and serve it to the browser, but that's slow.
Another way that i've found was using these signed urls of google's. My problem would be: how do i generate them in PHP using the current APIs from google ?
I doubt it's of any importance but i'm using phalcon as my backend framework.
Thanks.
from this article https://support.google.com/drive/answer/2881970?hl=en . google doesn't support web hostings. Is there any way that i can get my image from googledrive for example like this:
for example i have a shared folder like this:
https://drive.google.com/drive/folders/0ByzxsoB7kICPUjVEVG12a0hNSWc
and that shared folder contains with
myimage1.jpg,
myimage2.jpg,
myimage3.jpg,
i want to select/change it in my website by using that image.
For example i uploaded another image in my googledrive to replace my web image easily. Please help.
something like this :
<img src = "googledriveimage/myimage1.jpg">
after i want to replace the image. then i would go to googledrive and replace the myimage1.jpg with another image but the same file name.
You could write a PHP script to fetch the desired image from google drive and return it back to the HTTP client.
Refer to the flow in the diagram:
User views the HTML page in his/her browser
The browser sends a HTTP GET request to your PHP script.
The PHP script is hosted either in a publicy accessible web server (or uses a cloud service provider e.g. Google App Engine, you could use any cloud hosting service provider). The script would use the Google Drive SDK to use OAUTH and request the pre-specified image file from Google Drive. Here, you need to use either the SDK or wrap the request in the proper JSON/XML format as specified by Google Drive API. You need to embed the desired logic of translating a front-end visible image filename to the real Google Drive filename.
Google drive translates the request, checks authentication and retrieves the image.
The image is returned back to the PHP script.
The PHP script encodes the image and sets the right MIME type, headers, etc.
The user is able to view the image on the page.
To clarify, you dont need to host your PHP script in Google App Engine, you could host it on any other web hosting provider infrastructure.
I've used Google drive APIs in servlets deployed on Google App engine. I haven't used PHP in GAE, but have quoted the PHP references since you indicated familiarity with PHP. If you're interested in using GAE, first read the concepts related to GAE here https://cloud.google.com/appengine/docs/php/concepts and then the PHP how-tos for using the SDK and deploying the app using PHP - https://cloud.google.com/appengine/docs/php/how-to . Also refer to this documentation - https://cloud.google.com/appengine/docs/php/ .
I've included the concept of how you can solve your problem, you need to go through the documents and implement this yourselves.
) i am creating a php application in google appengine. Since i will have to pay for the cloud sql, i decided to use some files instead of the sql database and read/write from it. but the problem is i am not able to create or modify the existing files using php's standard file operations like 'fopen' and 'fwrite',etc. when i run the same code in 'localhost:8080' it is working properly. but not in the uploaded version in internet. i am getting errors while creating/writing to the files. please help. thank you
You should read the appengine php runtime docs https://developers.google.com/appengine/docs/php/#PHP_The_sandbox
Specifically the section about the sandbox. The crucial statement -
An App Engine application cannot:
write to the filesystem. PHP applications can use Google Cloud Storage
for storing persistent files. Reading from the filesystem is allowed,
and all application files uploaded with the application are available.
This was a while ago, but if you still want to write to file system, you can write to the gs cloud
https://cloud.google.com/appengine/docs/php/googlestorage/#writing_files_from_your_app
you need to add the bucket to your php.ini file
google_app_engine.allow_include_gs_buckets="yourapp.appspot.com"
and make sure your Service Account Name has permissions to edit the cloud storage
HTH
I want to develop a website like file manager. Where user register and will get fix disk space lets say 20MB.
Now user can upload their pdf, doc, txt, jpeg etc files upto their disk limit.
I can develop upto this using PHP.
Now below is my issue:
1) If user's files are corrupted they can rollback their folders before 2-3 days.
Files must be secure and safe from viruses as users are uploading their important documents.
Is there any 3rd party storage server who provides such facility?
2) Also all files should be previewed from browser.
I am using Google doc viewer. Is is good and safe way to preview file in browser?
But google links are accessible from all, I need to add some restrictions as file can be viewed only by their owner.
I know it's a major task, but i just need some sort of logic. Please share your thoughts.
Thanks.
Any cloud storage service can be used for this. You'll get HDD space. There is not storage server who provides revision control system for this. You can use git, svn for this though. But as the files are binary you can not get full facility of these tools.
How file will be previewed depends on you. If you use PHP you make the site and at the backend you use the API to interact with the storage service. Google doc is not an option for this if you use PHP. Also note Google links can be made private.
I suggest you this,
Find a cloud storage service and use the storage in your server. Any will do.
Create UI using PHP and control the access using PHP too.
Manipulate files in your server directly or in 3rd party storage server via API
Use a revision control system to track the changes. And use its API in PHP end.
Some cloud storage service
Amazon S3. It also supports Versioning.
Google Cloud Storage
Microsoft Azure
Try Microsoft SkyDrive or Google Drive or Dropbox