Files
Mint a presigned PUT URL for a user file upload
POST
/
agents
/
files
/
upload-url
JavaScript
import Mobilerun from '@mobilerun/sdk';
const client = new Mobilerun({
apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
});
const response = await client.files.uploadURL({
filename: 'x',
mimeType: 'x',
sizeBytes: 1,
});
console.log(response.expiresAt);import os
from mobilerun_sdk import Mobilerun
client = Mobilerun(
api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"), # This is the default and can be omitted
)
response = client.files.upload_url(
filename="x",
mime_type="x",
size_bytes=1,
)
print(response.expires_at)curl --request POST \
--url https://api.mobilerun.ai/v1/agents/files/upload-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "<string>",
"mimeType": "<string>",
"sizeBytes": 123
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mobilerun.ai/v1/agents/files/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([
'filename' => '<string>',
'mimeType' => '<string>',
'sizeBytes' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.mobilerun.ai/v1/agents/files/upload-url"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"sizeBytes\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.mobilerun.ai/v1/agents/files/upload-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"sizeBytes\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mobilerun.ai/v1/agents/files/upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"sizeBytes\": 123\n}"
response = http.request(request)
puts response.read_body{
"expiresAt": "2023-11-07T05:31:56Z",
"fileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"putUrl": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<unknown>",
"retryAfterSeconds": 123,
"traceId": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<unknown>",
"retryAfterSeconds": 123,
"traceId": "<string>"
}{
"code": "storage_limit_reached",
"details": {
"quotaBytes": 123,
"reason": "storage_limit",
"requiredBytes": 123,
"usedBytes": 123
},
"message": "<string>"
}{
"code": "idempotency_key_reused",
"message": "<string>",
"retryAfterSeconds": 123,
"traceId": "<string>"
}{
"code": "pending_uploads_limit",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<unknown>",
"retryAfterSeconds": 123,
"traceId": "<string>"
}{
"code": "storage_check_unavailable",
"message": "<string>",
"retryAfterSeconds": 30
}Headers
Idempotency-Key: 1-255 printable ASCII characters. Same key with a different request body is a 422 idempotency_key_reused. A retryable in-flight duplicate is a 409 with Retry-After and x-should-retry: true; a terminal duplicate is a 409 with x-should-retry: false. A replay returns the current resource state with Idempotent-Replayed: true.
Required string length:
1 - 255Pattern:
^[\x21-\x7E]{1,255}$Example:
"b3f6a9f0-6f1a-4e9a-9e7a-9c9b6b6a5a3f"
Body
application/json
Was this page helpful?
⌘I
JavaScript
import Mobilerun from '@mobilerun/sdk';
const client = new Mobilerun({
apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
});
const response = await client.files.uploadURL({
filename: 'x',
mimeType: 'x',
sizeBytes: 1,
});
console.log(response.expiresAt);import os
from mobilerun_sdk import Mobilerun
client = Mobilerun(
api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"), # This is the default and can be omitted
)
response = client.files.upload_url(
filename="x",
mime_type="x",
size_bytes=1,
)
print(response.expires_at)curl --request POST \
--url https://api.mobilerun.ai/v1/agents/files/upload-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "<string>",
"mimeType": "<string>",
"sizeBytes": 123
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mobilerun.ai/v1/agents/files/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([
'filename' => '<string>',
'mimeType' => '<string>',
'sizeBytes' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.mobilerun.ai/v1/agents/files/upload-url"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"sizeBytes\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.mobilerun.ai/v1/agents/files/upload-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"sizeBytes\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mobilerun.ai/v1/agents/files/upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"sizeBytes\": 123\n}"
response = http.request(request)
puts response.read_body{
"expiresAt": "2023-11-07T05:31:56Z",
"fileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"putUrl": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<unknown>",
"retryAfterSeconds": 123,
"traceId": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<unknown>",
"retryAfterSeconds": 123,
"traceId": "<string>"
}{
"code": "storage_limit_reached",
"details": {
"quotaBytes": 123,
"reason": "storage_limit",
"requiredBytes": 123,
"usedBytes": 123
},
"message": "<string>"
}{
"code": "idempotency_key_reused",
"message": "<string>",
"retryAfterSeconds": 123,
"traceId": "<string>"
}{
"code": "pending_uploads_limit",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<unknown>",
"retryAfterSeconds": 123,
"traceId": "<string>"
}{
"code": "storage_check_unavailable",
"message": "<string>",
"retryAfterSeconds": 30
}