Create URL File Uploads
Creating a URL file upload is a two-step process using the createSignedUrlFileUpload mutation.
Step 1: Create the upload and get a pre-signed URL
Call the createSignedUrlFileUpload mutation. This creates the upload record and returns a pre-signed S3 URL for uploading the file.
- Query
- Variables
- Response
- cURL
mutation CreateSignedUrlFileUpload(
$projectId: ObjectID!
$crawlTypeCode: CrawlType!
$fileName: String!
$projectUploadType: ProjectUploadType!
) {
createSignedUrlFileUpload(
input: {
projectId: $projectId
crawlTypeCode: $crawlTypeCode
fileName: $fileName
projectUploadType: $projectUploadType
}
) {
signedS3UploadUrl
urlFileUpload {
id
fileName
status
}
}
}
{
"projectId": "TjAwNlRlc3RTdWl0ZTEyMzQ",
"crawlTypeCode": "List",
"fileName": "url_list.txt",
"projectUploadType": "ListTxt"
}
{
"data": {
"createSignedUrlFileUpload": {
"signedS3UploadUrl": "https://s3.amazonaws.com/UrlFileUploads/12345/url_list.txt?X-Amz-Algorithm=...",
"urlFileUpload": {
"id": "TjAxM1VybEZpbGVVcGxvYWQ0MjMxOQ",
"fileName": "url_list.txt",
"status": "Draft"
}
}
}
}
curl -X POST -H "Content-Type: application/json" -H "apollographql-client-name: docs-example-client" -H "apollographql-client-version: 1.0.0" -H "x-auth-token: YOUR_API_SESSION_TOKEN" --data '{"query":"mutation CreateSignedUrlFileUpload( $projectId: ObjectID! $crawlTypeCode: CrawlType! $fileName: String! $projectUploadType: ProjectUploadType! ) { createSignedUrlFileUpload( input: { projectId: $projectId crawlTypeCode: $crawlTypeCode fileName: $fileName projectUploadType: $projectUploadType } ) { signedS3UploadUrl urlFileUpload { id fileName status } } }","variables":{"projectId":"TjAwNlRlc3RTdWl0ZTEyMzQ","crawlTypeCode":"List","fileName":"url_list.txt","projectUploadType":"ListTxt"}}' https://api.lumar.io/graphql
The required input fields are:
projectId- the Test Suite ID (Test Suites are a type of Project).crawlTypeCode- the crawl type, typicallyListfor URL list uploads.fileName- the name of the file being uploaded (must end with.csvor.txtfor List type).projectUploadType- the upload type, typicallyListTxtfor URL list uploads.
Optional fields:
enabled- whether the upload is active (defaults totrue).uploadBaseDomain- a base domain for resolving relative URLs in the file.
Step 2: Upload the file to S3
Use the signedS3UploadUrl from the response to upload your file directly to S3 via an HTTP PUT request:
curl -X PUT --data-binary @url_list.txt "<signedS3UploadUrl>"
The pre-signed URL is valid for 15 minutes, so make sure to upload the file promptly.
Step 3: Poll for processing status
After the file is uploaded to S3, it is automatically picked up for processing. Poll the upload status to track progress (see Retrieve URL File Uploads).
The upload transitions through the following statuses: Draft → Processing → Processed (or Errored).
caution
- It may take a while to process a URL file upload. Poll the
statusfield to check progress. - If the status changes to
Errored, check theerrorMessagefield for details.