My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

(JS + Drive API) Can I use a URI as a file location

mark barton's photo
mark barton
·Feb 25, 2019

I'm trying to create a simple upload feature to my web app using the Google Drive API. The current version of the app lets you download a project file (.json) to your local drive, but I want to edit this to add a feature that allows you to save it directly to the Drive API.

I have created a URI of the file before downloading it using:

var text = //JSON TEXT\\

("data:text/plain;charset=utf-8," + encodeURIComponent(text))

Because the Google Drive API requires a filepath argument in order to complete the request, is it possible to use this URI as a filepath? Or do I need to do somthing else like save to web server temporarily or save to local storage?

Appreciate any help.