curl --request POST \
--url https://api-dev.narrative.io/admin/companies/logo-upload-url \
--header 'Content-Type: application/json' \
--data '
{
"image_name": "logo.png"
}
'import requests
url = "https://api-dev.narrative.io/admin/companies/logo-upload-url"
payload = { "image_name": "logo.png" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({image_name: 'logo.png'})
};
fetch('https://api-dev.narrative.io/admin/companies/logo-upload-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/admin/companies/logo-upload-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image_name' => 'logo.png'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/admin/companies/logo-upload-url"
payload := strings.NewReader("{\n \"image_name\": \"logo.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/admin/companies/logo-upload-url")
.header("Content-Type", "application/json")
.body("{\n \"image_name\": \"logo.png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/admin/companies/logo-upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"image_name\": \"logo.png\"\n}"
response = http.request(request)
puts response.read_body{
"upload_url": "https://fake-test-cdn.s3.amazonaws.com/images/company-logos/local/companyId_1__56ff5f47-7660-4c0c-807e-af2c8a3e666b_logo.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20221206T163031Z&X-Amz-SignedHeaders=host",
"permanent_url": "https://fake-test-cdn.s3.amazonaws.com/images/company-logos/local/companyId_1__56ff5f47-7660-4c0c-807e-af2c8a3e666b_logo.png",
"expiry": "2022-12-06T17:00:31.098Z",
"content_type": "image/png"
}Get a presigned URL to upload company logo
Sending a file to Narrative is a two step process.
This endpoint allows you to request an upload_url which can be used in a PUT request to upload the file.
For example, once you have received an upload_url you could use it as follows:
curl -v --upload-file logo.png {upload_url}
The generated upload_url is only valid for 30 minutes after issuance.
Response also contains permanent_url, expiry, and content_type.
permanent_url should be used as long-term reference.
content_type should be used as Content-Type header since it is part of URL signature.
curl --request POST \
--url https://api-dev.narrative.io/admin/companies/logo-upload-url \
--header 'Content-Type: application/json' \
--data '
{
"image_name": "logo.png"
}
'import requests
url = "https://api-dev.narrative.io/admin/companies/logo-upload-url"
payload = { "image_name": "logo.png" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({image_name: 'logo.png'})
};
fetch('https://api-dev.narrative.io/admin/companies/logo-upload-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/admin/companies/logo-upload-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image_name' => 'logo.png'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/admin/companies/logo-upload-url"
payload := strings.NewReader("{\n \"image_name\": \"logo.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/admin/companies/logo-upload-url")
.header("Content-Type", "application/json")
.body("{\n \"image_name\": \"logo.png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/admin/companies/logo-upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"image_name\": \"logo.png\"\n}"
response = http.request(request)
puts response.read_body{
"upload_url": "https://fake-test-cdn.s3.amazonaws.com/images/company-logos/local/companyId_1__56ff5f47-7660-4c0c-807e-af2c8a3e666b_logo.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20221206T163031Z&X-Amz-SignedHeaders=host",
"permanent_url": "https://fake-test-cdn.s3.amazonaws.com/images/company-logos/local/companyId_1__56ff5f47-7660-4c0c-807e-af2c8a3e666b_logo.png",
"expiry": "2022-12-06T17:00:31.098Z",
"content_type": "image/png"
}Body
Name of the image that you want to upload.
"logo.png"
Response
List of companies
Presigned AWS URL, permanent URL and expiration.
"https://fake-test-cdn.s3.amazonaws.com/images/company-logos/local/companyId_1__56ff5f47-7660-4c0c-807e-af2c8a3e666b_logo.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20221206T163031Z&X-Amz-SignedHeaders=host"
"https://fake-test-cdn.s3.amazonaws.com/images/company-logos/local/companyId_1__56ff5f47-7660-4c0c-807e-af2c8a3e666b_logo.png"
"2022-12-06T17:00:31.098Z"
"image/png"
Was this page helpful?

