How to add files directly from Google Drive to MATLAB online?
57 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(2 个)
Shivam Kumar Singh
2020-7-5
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.
0 个评论
Richard Zapor
2023-6-17
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 个评论
Steve Van Hooser
2024-5-5
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Google 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!