This allows to upload a file to IPFS storage. The weightage for this API is 10
Upload file to IPFS Storage
This allows to upload file to IPFS storage under the given instance.
{
"Data": "QmbVnEgY9K1Qypb6Rqf81U8SfmoUfYNgTdsJm3JtvSTYKZ",
"Message": "IPFS storage created successfully",
"Status": "SUCCESS"
}
{
"message": "Missing API key found in request"
}
Take a look at how you might call this method using our official libraries, or via curl
:
curl --location --request POST 'https://api.krypcore.com/api/v0/storagemanageripfs/storefile' \
--header 'Authorization: xxxxx-xxxx-xxxx-xxxx-xxxxxxxx' \
--header 'DappId: xxx_xx_xx_xxxxxxx' \
--form 'files=@"/home/rajdeep/Downloads/download.png"'
var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');
var data = new FormData();
data.append('files', fs.createReadStream('/home/rajdeep/Downloads/download.png'));
var config = {
method: 'post',
url: 'https://api.krypcore.com/api/v0/storagemanageripfs/storefile',
headers: {
'Authorization': 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxx',
'DappId': 'xxx_xx_xx_xxxxxxx',
...data.getHeaders()
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
url = "https://api.krypcore.com/api/v0/storagemanageripfs/storefile"
payload={}
files=[
('files',('download.png',open('/home/rajdeep/Downloads/download.png','rb'),'image/png'))
]
headers = {
'Authorization': 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx',
'DappId': 'xxx_xx_xx_xxxxxxx'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
package main
import (
"fmt"
"bytes"
"mime/multipart"
"os"
"path/filepath"
"io"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.krypcore.com/api/v0/storagemanageripfs/storefile"
method := "POST"
payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
file, errFile1 := os.Open("/home/rajdeep/Downloads/download.png")
defer file.Close()
part1,
errFile1 := writer.CreateFormFile("files",filepath.Base("/home/rajdeep/Downloads/download.png"))
_, errFile1 = io.Copy(part1, file)
if errFile1 != nil {
fmt.Println(errFile1)
return
}
err := writer.Close()
if err != nil {
fmt.Println(err)
return
}
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "xxxxx-xxxx-xxxx-xxxx-xxxxxx")
req.Header.Add("DappId", "xxx_xx_xx_xxxxxxx")
req.Header.Set("Content-Type", writer.FormDataContentType())
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}