get files from google clous storage without using public url? - php

Hope you are doing well .
I’m working currently on a project that gets mp3 content from Google Cloud Storage into a web application to be played for users .
I just wanna know how I can get those audio files on streaming without downloading them in my project repo .
One approach is using a public Url , but I think that is not secure because people who know the url can access all my files stored in the cloud ?
I'm using php laravel

The only approach to this case I think is to use Signed URLs because we don't know whether they have a Google account.
Another solution that download the file locally on the server, and then let the user download the file from the server.

Related

How do you generate signed urls for google cloud storage objects in 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.

easily change/getting image from googledrive and display in website

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.

Is it possible to store files uploaded on your website to google drive?

We have our company website and we have many job opportunities often. So we have created a form where in interested candidates can apply directly. We also have a resume upload facility, right now resumes are uploaded and stored using PHP this resumes are stores onto our server, but we don't want to waste server space so we were thinking to just create one dedicated folder for resumes on Google drive and whenever user uploads his resume from our web site it will get stores onto a Google drive folder. Is this possible. We don't want to do it with Google forms or form+ since we have form matching our website theme.
It is possible to integrate into your website the Google Drive SDK which can allow you to do just that. You should look here for the PHP tutorial.
So yes, you can directly store the documents on the Google Drive using the API provided here. Look over here to access the more specifics for file uploading.
yes, it is possible with the php google class.
a very good example you can get from: http://hublog.hubmed.org/archives/001954.html

Download file from Internet and uploading to GDrive

So far, I've built a PHP script that downloads to a remote server of mine a file from Internet, provinding its URL (I've used this piece of code to download to the server).
Now I would like to upload the downloaded file on Google Drive using its API.
My question is: Is there a way to download the file directly to Google Drive, without using the server? Or I am forced to download the file first to the server and then upload it to Google Drive?
Thank you
I doubt if you can 'make' google drive get file from an external location...
However you do have an option to create a shortcut to the external file, if that suits you.
Also, If you wish continue direct upload you may refer this.
As far as I know the API doesn't allow to push files from another referer than the one that's calling the API. So, long story short:
First you need to download the file to your server, then upload it to gDrive from your server.
Read here more: https://developers.google.com/drive/examples/php#saving_files
Or here: https://developers.google.com/drive/manage-uploads

Loading secret FLV files from Amazon S3

I'm starting a new project that involves users paying to see educational videos. These videos (FLV) are hosted with Amazon S3 while the site itself is hosted on a regular web host.
I've tried to read up on securing the S3 files, and can't find any good solution for this. I don't want my users to download the videos directly.
I read something about setting up a HTTP streaming server, but I'm not quite sure how a service like this works, and how to set it up.
Anybody with any experiences on how to solve this?
You might like to look at s2Member for Wordpress - it has Amazon s3 protected files built in, with the time lapse thing, plus protected pages/ etc that you can setup pretty easily.
I don't want my users to download the videos directly.
Get used to it.
Even with an RTMP streaming server, it's pretty easy to save the streams. You can add a load of obfuscation at the server and decoder to try to defeat the automated tools, but in the end what you have here is the unsolvable Copy Protection Problem.
There is no way to hide network path from end-user. However, you can go using expiring passwords that depend on time, user and content-section if Amazon allows you to use .htaccess files or PHP scripts.

Categories