Code Monkey home page Code Monkey logo

Comments (9)

vinodc avatar vinodc commented on June 11, 2024

Hi @nathancarter Thanks for the words of appreciation. Yes that is possible. Set retrieve_token to true in the configuration options for the File Explorer, so your front-end/back-end service can make API requests authorized with the Bearer token. Your application can then use file update API endpoint (docs) to upload the updated file contents. If you do not have the file content and instead want to upload via a URL, use the upload endpoint (docs) with the URL, but set overwrite to true so it updates the existing file.

Your domain must be white-listed on the App Details page to retrieve the token.

from file-picker.

nathancarter avatar nathancarter commented on June 11, 2024

Thank you for the quick reply! That's great to hear. Even though I don't understand it all yet (since I haven't started tinkering with Kloudless yet, so I haven't learned the ins and outs of the API) this gives me confidence that I should give it a try, and I can return here when I need to learn how to do this. Thanks again.

from file-picker.

nathancarter avatar nathancarter commented on June 11, 2024

After digging a bit...I note that the docs suggest doing this via curl on the command line. My application is entirely client-side. Can this be done with AJAX and CORS or will api.kloudless.com reject an AJAX request of this type? Furthermore, is there a JavaScript API to accomplish this same task?

from file-picker.

vinodc avatar vinodc commented on June 11, 2024

@nathancarter HTTP requests via ajax would definitely work and won't be rejected due to CORS. You can reference our HTTP API documentation for how to perform the ajax request. We use curl to provide an example, but the HTTP request can be made from any client-side application.

from file-picker.

nathancarter avatar nathancarter commented on June 11, 2024

Nice!

from file-picker.

nathancarter avatar nathancarter commented on June 11, 2024

Just to close the loop on this, the reason I ended up not using Kloudless in the end is that I'm generating the content to save within the editor itself (obviously) rather than finding it somewhere as a URL on the Internet. And yet the Kloudless API doesn't support base-64-encoded data URIs, so I can't transmit the data directly to Kloudless from my client-side app. But thanks for all the help along the way!

from file-picker.

david-thorman avatar david-thorman commented on June 11, 2024

@nathancarter I am sorry to hear that you ended up not using Kloudless. I am somewhat confused by your requirement for base64-encoded data URIs for upload purposes. Typically our users perform uploads by sending the raw binary file contents in the request body or via multi-part encoded form. Could you clarify that requirement a bit more?

from file-picker.

nathancarter avatar nathancarter commented on June 11, 2024

I was essentially looking for a way to send data generated in the browser (e.g., the user typing a document into an editor in the page, then wanting to save that content) to Kloudless. Since I saw that Kloudless accepted URLs, the first thing that came to mind was to send a data URI containing the user's data. All the other examples I came across seemed to require some kind of server back-end in the app that wanted to access Kloudless, whereas my app is client-side only. Is there a different approach you'd recommend for client-side-only apps? Perhaps you have a pure JavaScript example of the binary upload you're describing?

from file-picker.

david-thorman avatar david-thorman commented on June 11, 2024

I am not able to write up a full example at the current time, but if you are able to load your data into a Javascript Blob object, then that can be sent via an XMLHttpRequest using the send method. You should be able to set the relevant headers prior to sending as well.

from file-picker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.