How to add files directly from Google Drive to MATLAB online?
조회 수: 58 (최근 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!