Displaying raw image files from Google Drive via API on a website - php

Why doesn't Google provide publicly accessible link to raw image files, which could be embedded in a website? As I've researched, they did allow it through G Suite a year ago, but not anymore, their reasoning being that there are other providers for this exact thing. As it stands now, it seems that the only possible way to achieve this is to first download the file via Google Drive API via your server and deliver it to the client. But this seems an overkill. What is your suggestion, should I switch to something else, e.g. Amazon S3, or is this solution scalable/economic enough? I picked Google Drive over Amazon S3 because it's free (at least to some extent).

Related

Any way to change the path from our API System to our Main System

We have 2 different system that's hosted to 2 different server. Let's call them API and CRM. The system we have on API obviously is all APIs and the CRM is our main system. So we also have this website where we can create a data in our Database.
I'm having trouble in finding a way to put the uploaded file from API to CRM server. The code is $upload->path = $folder.DIRECTORY_SEPARATOR.$date_append.$filename; and it looks like this "path/to/api/[date]-filename"
since $folder = storage_path('uploads');
So how do I make it path/to/CRM/[date]-filename instead of API where it's originally created?
if your API server is public and you don't mind using it as hosting for the image then you can use it in the CRM like this ex: https://apiserverdomain.com/path/to/CRM/[date]-filename.
but the best practice is to use Cloud Storage (like AWS S3 or Google Cloud or even FTP) and display the URL in your CRM from the Cloud Storage directly
I hope it's helpful

Laravel-PHP google drive API. Using different account to upload and share it throughout the site

I am making a web and mobile application that lets you upload files through google drive. the thing is my storage is getting low, somebody told me that i should find a way to upload files depending on the user, it means every user should upload files through their own google drive account and can access it or get a shareable link so the storage consumption would not be crowded with different kind of files. is there a way to do that, if not is there any other cloud storage that provides that kind of concept. Thanks in advance.
For application specific data, you may want to check Storing Application Data. The Google Drive API includes a special hidden folder that your app can use to store application specific data.
As discussed in the given documentation,
The App Folder is a special folder that is only accessible by your application. Its content is hidden from the user and from other apps. Despite being hidden from the user, the App Folder is stored on the user's Drive and therefore uses the user's Drive storage quota.
See if it will help you, otherwise you can use Google Cloud Storage or Firebase Storage as also suggested by Anwar Nairi. Both of these offer storage services which are ideal for your app. Drive API is meant for personal use.

Access Google Drive with PHP (or javascript)

I have a small site/web application where registered users can see some files that I periodically prepare for them; I store these files in separate directories and every user can only see and download their own files.
Now, I'm moving these directories to Google Drive and I would keep functionalities like file listing and downloading.
Reading the official docs I found some interesting examples about file download/upload, but all of them talk about authorization that user must give in order to access to their Drive and this is not what I'm looking for, I don't want access to their Drive!
As I can see, the doc is not contempling the case that someone may want to give (read-only) access to own Drive. But maybe I'm missing something...
Basically, I need the list of files on my Drive account and, if requested, a way to download one (or more). The only one that has the auth to Drive account is my server, users will send request from it.
Is it possible? I think yes, but I can't find any docs about that. How can I authorize my server?
I think you're looking for the Using OAuth 2.0 for Web Server Applications where you'll be using service accounts to achieve your goal.
"This document explains how web server applications use the Google API
Client Library for PHP to implement OAuth 2.0 authorization to access
Google APIs. OAuth 2.0 allows users to share specific data with an
application while keeping their usernames, passwords, and other
information private. For example, an application can use OAuth 2.0 to
obtain permission from users to store files in their Google Drives."
The snippets are in PHP too, so it works in your favor.

Youtube LiveStreaming API

I want to create a website where each user can create/start live streaming.
But as I can see for now I can only create a stream for my own account. The one in which Youtube Data API is enabled. The one which secret keys are written in code. So I have no permissions to create live stream from someones account.
My question is if it is possible to do with Youtube API or not?
UPDATE
I found the way to add broadcast to user's account. But I can't understand how to tell user how to stream to created broadcast. He needs stream_key. (As I know...cause I use OBS software for windows and the only thing I need is stream_key to start streaming.
Never mind. I found out myself. If somebody has same question...
I need to choose Custom Streaming Server in OBS. And in this case I need URL and Stream Key. Which I can get from $streamsResponse['modelData']['cdn']['ingestionInfo']['strea‌​mName'] and $streamsResponse['modelData']['cdn']['ingestionInfo']['inges‌​tionAddress']
This may be a bit more advanced than using OBS, but you could use Wowza's GoCoder livestreaming SDK to build a mobile app. Your subscribers/users can generate a livestream from their mobile phones > to Wowza Media Server > final stream target destination configured for You Tube live.
It works directly with the You Tube Live API.

Google Glass - Share Images

I'm developing a "sharing" app for Google Glass using the Mirror API.
Basically, I want there to be another share option on the images and videos. Instead of just the default "Share to Google Plus," there will also be "Share to (Server)," which will ping a file (upload.php) on the server to upload the image/video.
From the documentation I can tell I need to use contacts to "subscribe" to the share events.
Could someone point me to a doc that explains how this can be done? I know it is possible because apps like YouTube and Facebook already achieve this.
Here's an example in various languages, including php:
https://developers.google.com/glass/v1/reference/contacts/insert#examples
You may also want to play around with the Quickstart demo app (which can also be downloaded on GitHub):
https://developers.google.com/glass/develop/mirror/quickstart/php
The Quickstart is a working demo that showcases the Contacts, Subscribe, and Timeline capabilities of the Mirror API.

Categories