How to add files directly from Google Drive to MATLAB online?

56 vues (au cours des 30 derniers jours)
debapriya t
debapriya t le 24 Juin 2020
I have a dataset(as a zip file) which is of around 1 GB, in my Google Drive. I want to upload it directly to MATLAB online without downloading it first into my local machine, and uploading to MATLAB drive for accessing via MATLAB online. I know that websave is a useful command when I have direct download links to datasets.
So what I tried is:
1) Make a shareable link of the zip file and provide access to everybody.
2) Convert it into a download link using Google Drive Direct Link Generator(https://sites.google.com/site/gdocs2direct/).
3) Used the link generated by above to download using websave.
But, that doesn't work and it simply returns some HTML code into the file I write to. I used websave both with and without the extension '.zip' as filename, but neither worked.
Please tell me how I should do so then.
P.S.: I created the zip file using Google Colab by writing directly into Google Drive.

Réponses (2)

Shivam Kumar Singh
Shivam Kumar Singh le 5 Juil 2020
As far as I am aware, there are no APIs to do this currently. However, you can use a file stored in dropbox in matlab. There are functions available on exchange for it. If possible, you can explore dropbox.

Richard Zapor
Richard Zapor le 17 Juin 2023
I assume you want to download your zip file to your HD. Your html content problems will be solved by the below. The function websave creates a fname and writes the file to the HD. z004=websave('2.png','https://drive.google.com/uc?export=download&id=1v3GsGgP3p905wzdvUqypL_-djYmxiyzK'); z004 became a local path of a valid file.
Two changes are required to download from a google drive.
1) Set the privilege to Anyone with the link for the file using the triple dots
2) Given a filename of below format: tweak- file/d to uc?export=download&id= while removing /view?usp=sharing
https://drive.google.com/file/d/1RbPkr6KxZCuv_d4c0q5DONooqHArxoS0/view?usp=sharing tweak it to
https://drive.google.com/uc?export=download&id=1RbPkr6KxZCuv_d4c0q5DONooqHArxoS0
if resourcekey=RESOURCE_KEY exists then also include at the end per Overleaf
Works for urlwrite and imread
urlwrite('https://drive.google.com/uc?export=download&id=1v3GsGgP3p905wzdvUqypL_-djYmxiyzK','2.png');
img=imread('https://drive.google.com/uc?export=download&id=1v3GsGgP3p905wzdvUqypL_-djYmxiyzK','png')
img2=imread('https://drive.google.com/uc?export=download&id=1v3GsGgP3p905wzdvUqypL_-djYmxiyzK');
solution credit to https://www.overleaf.com/learn/how-to/How_can_I_upload_files_from_Google_Drive%3F
  1 commentaire
Steve Van Hooser
Steve Van Hooser le 5 Mai 2024
Hi Richard -
Thanks for the tip. However, this does not work for me for downloading files that trigger a "too big for virus scanning" warning. Instead, it produces the HTML that prompts the user to agree to download it anyway.
Best
Steve

Connectez-vous pour commenter.

Catégories

En savoir plus sur Google dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by