Chapter 2: Audio
Get Presigned AWS URL
getPresignedAwsUrl
query can be used to generate the pre-signed URL, it generates pre-signed URL for uploading audio securely to an S3 bucket
Query Information
-
Supported file extensions for upload include:
.mp3
,.mp4
,.wav
,.mkv
,.webm
,.ogg
,.m4a
,.aac
,.opus
,.wma
. -
The
uniqueObjName
parameter should be a randomly generated string consisting of 30 characters, made up of alphanumeric characters, followed by the file extension of the uploaded file. -
The query returns a response if the user, identified by the Auth Key, still has a budget available to spend.
Example GraphQL Query (GET_PRESIGNED_URL):
export const GET_PRESIGNED_URL = `
fragment awsUrlObject on AWSUrlObject {
url
fields
}
query GetPresignedAwsUrl($uniqueObjName: String!) {
getPresignedAwsUrl(uniqueObjName: $uniqueObjName) {
...awsUrlObject
}
}
`;
Example Data Object for GET_PRESIGNED_URL Mutation
{
query: GET_PRESIGNED_URL,
variables: {
uniqueObjName: "SNbssr4Ls7Yzf3jMxXIK.ogg"
},
}
Example JS code to obtain the pre-signed url
import axios from "axios";
const fetchPresignedUrl = async () => {
try {
const response = await axios({
method: "POST",
url: "https://your-graphql-endpoint.com/graphql",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.VUE_APP_API_KEY,
},
data: JSON.stringify({
query: GET_PRESIGNED_URL,
variables: {
uniqueObjName: "SNbssr4Ls7Yzf3jMxXIK.ogg",
},
}),
});
console.log('Presigned URL:', response.data.data.getPresignedAwsUrl.awsUrl);
} catch (error) {
console.error('Error fetching presigned URL:', error);
}
};
fetchPresignedUrl();
Have questions?
Still have questions? Talk to support.