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
Related
How to upload a file to Google Drive using the API by a url(Remote Upload)? I read the doc and I did not find any option like DropBox where save_url() can be used to remote upload.
But, there are a lot of sites which allows remote upload to Google Drive, so it must be possible.
You may refer with this tutorial on how to directly upload files from the web to Google Drive without saving them completely on the server before. This is useful to upload files, which are bigger than the storage available on the server.
How to use it:
Rename "credentials/oauth-credentials_EXAMPLE.json" to "credentials/oauth-credentials.json"
Download your oauth2 credentials in the google developer console and copy it in it
Call the "index.php" from the console ("php index.php")
Follow the messages in the console window
Create pull requests to help with the development
Hope this helps!
I am in a situation where I have to upload a PDF file through an API, all of the examples that I have encountered point towards a specified file location, where uploaded through a form or in a specified location on a computer/server.
The issues arises that the PDFs that I have to attach are being provided to me as direct download links. Are there any solutions that would work off of my Virtual Machine setup of Dreamfactory?
So are you trying to POST a PDF file using DF files service? And are you saying the only way to get the file is via a direct download link? I'm not sure I fully follow what you are trying to achieve but the DreamFactory scripting may be able to help you implement this.
I am working to create a script that scans our company Google Drive folders and copies any new files into a Repository directory on my server.
So far I can connect to GDrive, read all files, edit files, but I am unable to download via PHP. copy() file_get_contents() file_put_contents() etc. Are not working.
I imagine the solution is to use Google Apps Script to download and copy the file to my server directory, but I do not see the correct class.methods in the documentation.
How can I copy a GDrive file to my server using Google Apps Script?
You could run some code through Google Apps Script to upload the files to your server. In that case you need to use UrlFetchApp.fetch, which despite its name can also do an HTTP POST with arbitrary data. There is an example for uploading files in the API documentation.
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
I need to upload a video to YouTube but without the video being on my web server. I have videos on a separate storage server, and the PHP is on a web server, I understand and got it working to upload a video to YouTube which is in my public web server folder.
It's simply as you only need to provide the location of the file, like $videoPath=sfConfig::get('sf_root_dir').'/web/tmp.mp4', however, going on with this code my web server would have to download the file from my storage server and then set the path of the video, but that would lead to too much bandwidth usage of my web server. What I'd like to do is something like $videoPath="http://storageserverurl.com/tmp.mp4" but that isn't possible.
Here is the piece of code that downloads the file to the web server and sends it to YouTube, it's working without problems.
file_put_contents("tmp.mp4", file_get_contents("http://storageserver.com/tmp.mp4"));
$videoPath=sfConfig::get('sf_root_dir').'/web/tmp.mp4';
I'd like it to be something like $videoPath="http://storageserver.com/tmp.mp4";
The rest of the code is the sample code given by Google. I'm using PHP 5.6.3 with symfony 1.4.
I'm trying to build a basic web application using the Dropbox API. I have the file upload/folder listing etc. working but cannot find in the documentation how to force the file to download to the user's browser. Is this possible?
If it is can someone point me in the right direction? I'm using the standard PHP SDK.
Dropbox.com: How do I force a file to download from the web
Force a file or folder to download
To cause the browser to download a file or folder rather than display
it, you can use dl=1 as a query parameter in your URL. For example:
https://www.dropbox.com/s/qmocfrco2t0d28o/Fluffbeast.docx?dl=1 Note
that the original share link URL may contain query string parameters
already (e.g. dl=0), so app developers should make sure to properly
parse the URL and add or modify parameters as needed.
And if that doesn't suffice you can check Wikihow: How to Force a File to Download from the Web on Dropbox, with nice screenshots.
If this is not what you had in mind you have clarified that in your question. You still can do that now.