13 Uploading a File to a Batch using API
To upload a file to a batch, complete the following steps:
- Request for PAR (Pre Authenticated Request)
- Upload the file with provided PAR
- Mark the Batch execution status to FileUploadCompleted
Request for PAR
This POST request accepts the required file information like FileName, FileContentType and batch related information like ScheduledDtTm and BatchConfigUuid.
Request:
POST /batch-api.services/batch-api/Batch/v1/BatchRec/?requestedAction=BatchFileUpload
{
"BatchInfo": {
"FileName" : "BatchFileUploadTest",
"ScheduledDtTm": "2024-11-20T10:47:31.502698Z",
"FileContentType": "application/json",
"BatchConfigUuid": "D0470F999C9941AFB6A6D1965865CF5A"
}
}
Response
{
"FileMasterInfo": {
"FileRec": {
"FileInfo": {
"Name": "fileName2",
"ShortName": "",
"FileContentType": "application/json",
"FileOrigin": "External",
"FileReference": "v1-8b4f2652-1d6b-4424-9741-d40809a14720"
},
"Status": {
"HasMore": false,
"Layers": 3,
"Links": [
{
"rel": "self",
"href": "file-api/A4A34E43FF4A4E31BC0FFD0E15386807/File/v1/FileRec?totalResults=false&limit=10&offset=0&layers=3"
}
],
"Items": [
{
"StatusCode": "In Progress",
"EffDtTm": "2024-05-31T00:00:00.000000Z"
}
]
},
"FileUuid": "A4A34E43FF4A4E31BC0FFD0E15386807"
},
"FilePreAuthenticatedRequestRec": {
"FilePreAuthenticatedRequestInfo": {
"FilePARAccessType": "Write",
"FilePARRequestDurationUnit": "Day",
"FilePARRequestDuration": 7,
"FileUuid": "A4A34E43FF4A4E31BC0FFD0E15386807",
"FilePARURL": "https://objectstorage.us-phoenix-1.oraclecloud.com/p/LZFtUKJJNeb15ceAviYCVJqqf-Xu1v-DN6DIFvfUqpRQ2DZE4Fqb-3UHCsKqtr9S/n/oraclegbudevcorp/b/fsgbu_fsc_cndevcorp_dev_s1d-rdo-sbox1_nonprod_src/o/v1-8b4f2652-1d6b-4424-9741-d40809a14720"
},
"Status": {
"HasMore": false,
"Layers": 3,
"Links": [
{
"rel": "self",
"href": "file-api/DBEA56CD245F4A84A10DA79B2BE6CF29/File/v1/FilePreAuthenticatedRequestRec?totalResults=false&limit=10&offset=0&layers=3"
}
],
"Items": [
{
"StatusCode": "In Progress",
"EffDtTm": "2024-05-31T00:00:00.000000Z"
}
]
},
"FilePreAuthenticatedRequestUuid": "DBEA56CD245F4A84A10DA79B2BE6CF29"
},
"FileEntityRelRec": {
"FileEntityRelInfo": {
"EntityType": "BatchRec",
"EntityUuid": "0DC949E164FC4EE898497E35DA083515",
"FileUuid": "A4A34E43FF4A4E31BC0FFD0E15386807"
},
"Status": {
"HasMore": false,
"Layers": 3,
"Links": [
{
"rel": "self",
"href": "file-api/E67B9665CF0749BF8A7480079A66E5A7/File/v1/FileEntityRelRec?totalResults=false&limit=10&offset=0&layers=3"
}
],
"Items": [
{
"StatusCode": "In Progress",
"EffDtTm": "2024-05-31T00:00:00.000000Z"
}
]
},
"FileEntityRelUuid": "E67B9665CF0749BF8A7480079A66E5A7"
}
}
}
Corresponding PAR is generated for the file with batch status as FileUploadRequested.
PAR URL is associated to attribute as FilePARURL in response body.
Upload the file with the provided PAR
Upload the file to the PAR URL:
curl -X PUT -H "content-type: application/json" -d @<inputFileName> https://objectstorage.us-phoenix-1.oraclecloud.com/p/W5jlt8odhzaOeICBmOOLXbidBGjbJAH9lkOLXF6Em5WG_U3i0LphNyvx4lsKncQy/n/oraclegbudevcorp/b/fsgbu_fsc_cndevcorp_dev_s1d-rdo-sbox1_nonprod_src/o/v1-a72727cb-5e3a-44f1-992e-7f24fc3bfb0e
Mark the Batch execution status to FileUploadCompleted
This step indicates Batch instance is ready for the execution and will start its execution as per the schedule.
Request
PUT /batch-api.services/batch-api/Batch/v1/BatchRec/7D554ED2896F4EE8BAA0F97CF963513A/requestedAction=TransitBatchExecutionStatus
{
"BatchInfo": {
"BatchExecutionStatus": "FileUploadCompleted"
}
}
{
"BatchInfo": {
"BatchConfigUuid": "D0470F999C9941AFB6A6D1965865CF5A",
"BatchExecutionStatus": "FileUploadCompleted",
"ScheduledDtTm": "2024-11-20T10:47:31.502698Z",
"BatchAdhocExecutionInd": true,
"ExecutionStartDtTm": "2025-01-24T12:49:11.874835Z"
},
"BatchUuid": "7D554ED2896F4EE8BAA0F97CF963513A"
}