Vianney Sserwanga
Vianney Sserwanga

Reputation: 313

Nitrogen - File upload directly to database

In the Nitrogen Web framework, files uploaded always end in the ./scratch/ directory when using #upload{}. From here you are supposed to manage the uploaded files, for example, by copying them to their final destination directory.

However, in case the destination is a database, is there a way of uploading these files straight to the database? Use case RIAK-KV.

Upvotes: 1

Views: 65

Answers (1)

Peter Clark
Peter Clark

Reputation: 76

You can upload a file to Riak KV using an HTTP POST request. You can see the details at in the Creating Objects documentation which shows how to do it using curl.

To send the contents of a file instead of a value, something like this should work:

curl -XPOST http://127.0.0.1:8098/types/default/buckets/scratch/keys/newkey
-d @path/to/scratch.file
-H "Content-Type: application/octet-stream"

Upvotes: 1

Related Questions