Hello @zackyew - welcome to the Bluescape Developer Community!
Sorry the “Upload Content into a Canvas for v3” guide didn’t help you with Document/pdf.
The short answer is REST body for pdf:
const zygote_body = {
"type": "Document",
"filename": "graphQL_intro.pdf",
"documentFormat": "pdf",
"transform": { "x": 300, "y": 100, "scale": 1 }
}
For a deeper explanation, if you are uploading a document from disk, it needs to be be done in 3 steps:
- call Bluescape
createDocument
mutation to get the s3 keys needed to upload the document to s3
- upload the document to s3 using response from step 1
- (optional step to also upload a preview document preview)
- Complete the upload transfer by calling Bluescape
processAsset
mutation after receiving 204 response from step2.
You can find a sample a sample graphQL NodeJs application on our community github that demonstrates uploading files from disk and by URL:
GraphQL
you can navigate the graphQL documentation with our graphQL playground
- Step1:
createDocument
mutation
#create Document from disk
#formats: doc docx ppt pptx xls xlsx pdf docMime docxMime pptMime pptxMime xlsMime xlsxMime pdfMime
mutation createNewAssetFromLocal($workspaceId: String!, $input: CreateDocumentInput!){
newAsset: createDocument(workspaceId: $workspaceId, input: $input) {
__typename
content{ uploadId url fields}
document {id width height ingestionState}
}
}
input variables:
{
"workspaceId": "{{workspaceID}}",
"input": {
"title": "./files/graphQL_intro.pdf",
"filename": "./files/graphQL_intro.pdf",
"transform": {"x":0, "y":0},
"documentFormat": "pdf"
}
}
- Upload the Document to s3 with keys etc from step1:
curl --location 'https://s3.us-east-1.amazonaws.com/public-assets.bluescape.com' \
--form 'key="sessions/objects/workspaceId/uploadId.pdf"' \
--form 'bucket="public-assets.bluescape.com"' \
--form 'X-Amz-Algorithm="AWS4-HMAC-SHA256"' \
--form 'X-Amz-Credential="sampleCredential"' \
--form 'X-Amz-Date="20230523T200212Z"' \
--form 'Policy="samplePolicy"' \
--form 'X-Amz-Signature="sampleSignature"' \
--form 'file=@"/developerProgram/graphQL_intro.pdf"'
- after 204 response, or error inform Bluescape of s3 upload status:
#complete the asset upload using the uploadID obtained from
#createImage, createVideo, createDocument
mutation myProcessAsset($workspaceId: String!, $uploadId: String!, $errorDataToReport:TransferCompleteInput! ) {
processAsset( workspaceId:$workspaceId id:$uploadId input:$errorDataToReport)
}
input variables:
{
"workspaceId": "{{workspaceID}}",
"uploadId" : "{{Amz-uploadId}}",
"errorDataToReport":{
"errorCode": null,
"errorMessage": null
}
}
REST:
- Step1 create element endpoint documentation: POST /v3/workspaces/{workspace}/elements
curl --location 'https://api.apps.us.bluescape.com/v3/workspaces/IPvtDuI2Eh7DAdsI6ciu/elements' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{yourToken}}' \
--data '{
"type": "Document",
"filename": "graphQL_intro.pdf",
"documentFormat": "pdf",
"transform": { "x": 300, "y": 100, "scale": 1 }
}'
- you can find the appropriate request body in the schema for createDocument
- Step2 upload to S3 (same as above)
- step3 process the result of s3 upload success/failure
curl --location --request PUT 'https://api.apps.us.bluescape.com/v3/workspaces/{{workspaceId}}/assets/uploads/{{s3UploadId}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data '{}'
I hope this helps you navigate our developer resources for both REST and graphQL and helps solve your issue with document upload!