Is the only way to download a file through Google Drive through the download_url that is provided? I have the file_id and would like to make one simple call to download the file. Right now it looks like you have to make one call to fetch the file metadata and retrieve the download_url, then another to actually download the file. Is this the only way?
Also, the download_url is described as a "short lived url". How long will this url be available for?
Thanks
Using the download_url is the correct way to download a file from Drive. I'd strongly advise against trying to build the download urls yourself as the resulting code will be likely to break.
A download_url is usually available for hours, but instead of relying on that you should always retrieve the updated file before downloading a file from Drive. More information at this other question: How long does the Google Drive SDK "short lived" download URL exist for?
Related
I have found documentation for uploading an image from iOS to a blob container in Azure - https://learn.microsoft.com/en-us/azure/storage/blobs/storage-ios-how-to-use-blob-storage
using the https://github.com/Azure/azure-storage-ios library
But I wish to upload directly to a file share. Is there a way to do this?
It needs to be implemented using SAS authentication.
Unfortunately I am not familiar with iOS programming thus I will not be able to provide you any code. However you can use the steps below to write code.
Assuming you have a SAS URL for the file share in which you wish to upload the file, you can simply use Azure Storage REST API to upload the file in a file share. You should be able to use built-in HTTP functionality in the programming language of your choice to do that.
Let's assume that you have a SAS URL for the file share in the following format: https://<account-name>.file.core.windows.net/<share-name>?<sas-token>.
First thing you would need to do is insert the file name that you wish to upload in this SAS URL so that you get a SAS URL for the file. Your SAS URL would look something like: https://<account-name>.file.core.windows.net/<share-name>/<file-name>?<sas-token>.
Next you would need to create an empty file. You will use Create File REST API operation. Do not worry about the Authorization request header there as it is already included in the SAS. Only request header you would need to include is x-ms-content-length value of which should be the size of the file you want to upload. This will create an empty file having size as that of the file you want to upload.
Once this operation completes, next you would need to upload the data in the empty file you just created. You will use Put Range operation. The request headers you need to include are x-ms-range (value of which should be bytes=0-file-length - 1) and Content-Length (value of which should be the length of your file). The request body will contain the file contents.
Using these steps you should be able to upload a file in a file share.
as I'm not a web developer by any means, this is me just asking a question for that I have not found a solution for.
I have a google sheet with multiple pages/sheets within it. the file is embeded in an iframe inside a webpage and I pulled the url and can open it directly using the url. the following link is just an example as I can't share the actual link since I am not allowed to:
https://docs.google.com/spreadsheets/d/e/{key}/pubhtml?widget=true&headers=false
I have tried this:
https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key={key}
and is not working I get an error:
Sorry, unable to open the file at present.
Please check the address and try again.
the file is not meant for anyone to download nor share. Furthremore, since it is continuosely manually updated by author and I need to keep track of updates, taking screenshots is not efficient since the file is too big.
is there any way I can download the actual sheet to my device (so I can compare file updates over the long run)
Thank you.
I believe your goal as follows.
You want to download a Google Spreadsheet.
You are the owner of Google Spreadsheet.
The Spreadsheet is published as the Web publish. So the URL of Spreadsheet is https://docs.google.com/spreadsheets/d/e/2PACX-1vTl9bcwMSjoxYj406evzJefFodkVEUlV2KIq34Y5V8BFWJygAFrPSA7L5d89TASDUjkPG4b2SfN2rpe/pubhtml?widget=true&headers=false.
Issue and workaround:
Unfortunately, the Google Spreadsheet cannot be directly downloaded as the Google Spreadsheet. It seems that this is the current specification. In this case, it is required to export the Google Spreadsheet as other mimeType. For example, it's XLSX format, PDF format and CSV format. But the URL of https://docs.google.com/spreadsheets/d/e/2PACX-1vTl9bcwMSjoxYj406evzJefFodkVEUlV2KIq34Y5V8BFWJygAFrPSA7L5d89TASDUjkPG4b2SfN2rpe/pubhtml?widget=true&headers=false cannot directly export. So, in this answer, as a workaround, I would like to propose to use the URL for exporting Google Spreadsheet as other mimeType.
When your URL is used, the URL for exporting is as follows.
Modified url:
https://docs.google.com/spreadsheets/d/e/2PACX-1vTl9bcwMSjoxYj406evzJefFodkVEUlV2KIq34Y5V8BFWJygAFrPSA7L5d89TASDUjkPG4b2SfN2rpe/pub?output=xlsx
In this case, when you access to above URL using browser, your Spreadsheet can be exported as a XLSX file.
When output=xlsx is modified to output=pdf and output=csv, you can export as a PDF file and a CSV file, respectively.
When you want to export the specific sheetm please use the sheet ID like gid=0. The URL is as follows.
https://docs.google.com/spreadsheets/d/e/2PACX-1vTl9bcwMSjoxYj406evzJefFodkVEUlV2KIq34Y5V8BFWJygAFrPSA7L5d89TASDUjkPG4b2SfN2rpe/pub?output=xlsx&gid=0
Note:
When you want to make users downloading the Spreadsheet, you can add the tag a as follows.
Download
I have a Rails application which is suppose to upload images from a Dropbox URL pointed to a folder. The folder contains the images. Application is suppose to upload all images present in folder.
The URL is somewhat like this
https://www.dropbox.com/sh/17fsm6bsnac1g4q/AADJ7B2L0OIrkSrc7YcG-OO9a?dl=0
I can see the images but how can I get the list of all images URL. I have tried parsing the URL by appending dl=1 which downloads the images.
URI.parse('https://www.dropbox.com/sh/17fsm6bsnac1g4q/AADJ7B2L0OIrkSrc7YcG-OO9a?dl=1).
How can I get the URL of all images. If I can not get URL of images then how can i download all images and them upload them.
If you are okay with just downloading everything, you can make a GET request to the dl=1 version of the link you have. This URL parameter is documented here. This will give you a zipped version of the folder which you can then unzip and use as necessary.
Dropbox doesn't offer a way to get links for each of the files in the linked folder, but you can use the Dropbox API to list the files and then download them individually. You can use the /2/files/list_folder endpoint and pass the shared link in as the shared_link parameter. That will give you a list of the items in the folder.
You can then use /2/sharing/get_shared_link_file to download any desired file(s), by passing in the shared link as the url parameter, and the relative path for the file as the path parameter.
I'm using NSURLSessionDownloadTask to download some .mov files from a web and storing them in my app.
Now what I'd like to achieve is to
download ALL files of certain type (in this case .mov) available on the page, without having to specify every file URL
download files ONLY if they are not already stored in my app.
Is there any way to achieve this?
You would have to scrape that html page to get all the urls (.mov) you are looking for. Either you can use NSXMLParser if you want to write your own or you can google some library.
When you download a file, persist some metadata (eg. name or some unique identifier) either in SQLite or CoreData, so that you can check if the file has already been downloaded.
I've got a working system to upload to the default root using resumable uploads and I've been able to make the meta data in a collection but I need to be able to do this type of upload straight to a collection or sub collection.
My main problem is the url, there's no defined example of a straight upload path to a collection?
I assumed that it would be like:
https://docs.google.com/feeds/upload/create-session/default/private/full/folder%3A[folder_id]/contents
considering that the typical upload path is similar except without the upload/create-session part?
In a folder entry, look for a link like this:
<link rel="http://schemas.google.com/g/2005#resumable-create-media"
type="application/atom+xml"
href="https://docs.google.com/feeds/upload/create-session/default/private/full"/>
The href is what you need to send to to create the file in that folder.
p.s. Have you considered using the new Drive API? It has this funcitonality and is considerably better to use.
Turns out I was originally correct and the URL I provided was correct for uploading but the function I created for generating the URL was missing out the / between feeds and upload