How to Use Google Drive Hosted Files with StageNow - updated for new Gdrive link format
This blog details a method to convert a Google Drive link so that it can be used in a StageNow profile for downloading files to a Zebra device. The main advantage of this approach is that Google Drive offers 15GB of free storage which can be used to create internet-hosted staging profiles .GDrive also creates links which do not expire ( https://oit.williams.edu/announcements/you-can-put-a-time-limit-on-shar… ) unless you specify an expiry date unlike other file storage providers such as Microsoft OneDrive (which only offers 5GB free storage without a subscription)
- Zip the file(s) to be staged to the device before uploading to Gdrive
- In Gdrive, create a link to the file via GetLink , select ‘Anyone with the link’ and copy link
- The format for exported link is similar to this (fileID is highlighted in yellow):
https://drive.google.com/file/d/1jbuDBd2t6S2PvbzE2igB4fG87yEfnEqR/view?usp=sharing
-
Create a Google Drive API key using the method 1 detailed here: https://bytesbin.com/skip-google-drive-virus-scan-warning-large-files/
-
The generic URL format for a direct file download from GDrive is as follows:
https://www.googleapis.com/drive/v3/files/FileID?alt=media&key=APIKey
where FileID= the unique file ID (varies for each file) highlighted in yellow above
APIKey= your GDrive API key obtained in previous step
6. Create a modified URL using the format above – this will allow direct download of the file linked to this fileID e.g.
Original share link:
https://drive.google.com/file/d/1jbuDBd2t6S2PvbzE2igB4fG87yEfnEqR/view?usp=sharing
Modified share link:
- If using a StageNow profile , the modified link can be used directly in the FileMgr Source File URI field to access the file :
- If using XML , the link has to be shortened in order to embed it in XML . Copy the link and paste in a URL shortener e.g. https://free-url-shortener.rb.gy/ to create a short URL e.g.
- Copy the short URL for use as the source file in the XML as shown in the examples below:
To unzip the contents of the ZIP file e.g. for APK files, data files etc ( note that zip file contents will be unzipped to the destination folder specified in ArchiveTargetPathAndFolderName )
<characteristic type="FileMgr" version="10.1" >
<parm name="FileAction" value="9"/>
<characteristic type="file-details">
<parm name="IfDuplicate" value="1" />
<parm name="ArchiveTargetPathAndFolderName" value="/sdcard/Download"/>
<parm name="ArchiveSourceURI" value="https://rb.gy/1h0kno"/>
</characteristic>
</characteristic>
When profile is processed the zip file will be downloaded and extracted with status message similar to the following :
- To transfer the ZIP file ‘as is’ e.g. for OS update files:
<characteristic version="0.6" type="FileMgr">
<parm name="FileAction" value="1" />
<characteristic type="file-details">
<parm name="TargetAccessMethod" value="2" />
<parm name="TargetPathAndFileName" value="/sdcard/Download/HE_DELTA_UPDATE_11-23-13.00-RG-U01-STD_TO_11-23-13.00-RG-U07-STD.zip" />
<parm name="SourceAccessMethod" value="1" />
<parm name="SourceURI" value="https://rb.gy/18bubr" />
</characteristic>
</characteristic>
For a full OSUpgrade example please refer to the associated blog post which covers this topic specifically: https://developer.zebra.com/blog/zebra-os-upgradedowngrade-gdrive-hosted-files
Ian Hatton
11 Replies
Would this also work for OS upgrade or do we need to have the zip file name in the URL ?
Yes - will work for OS upgrade and downgrade - the filename is not required in the URL as the Gdrive link refers to the specific file which has been shared.
hello, i don't know how to download files from sharepoint, my company blocks google driver
This method only works with Gdrive - I have not found an equivalent method which works with Sharepoint links unfortunately
Hello
Hello.
I get the error message "Query Error, Reason-FMC Download Failed!!! No Redirection supported"
Even though I used only the link in the tutorial article, the network is not blocked from accessing the Google driver link
I am using MC33 android 7
Hi, for a few days I have no longer been able to use gdrive with StageNow. It has always worked correctly. I attach the image of the message.
The error being reported is due to a change Google made in the format of the direct file download link which now requires the addition of a Gdrive API key. Please refer to the related article here ( https://developer.zebra.com/blog/zebra-os-upgradedowngrade-gdrive-hosted-files ) which has the new link format and I will also update this blog in the next week or so.
Since today I get the below error for downloading files which worked fine yesterday.
FileMgr
Exception, FileAction-Downnload Failed With HTTP Error Code 403
I see the same thing and via a browser I get the message below. Looks like a Gdrive issue so it could be worth opening a support ticket with Google if it does not clear by itself sometime today ?
{ "error": { "code": 403, "message": "The download quota for this file has been exceeded.", "errors": [ { "message": "The download quota for this file has been exceeded.", "domain": "usageLimits", "reason": "downloadQuotaExceeded" } ] } }