Я использую FedEx REST API для загрузки изображений (
Код: Выделить всё
/documents/v1/lhsimages/uploadКод: Выделить всё
[errors] => stdClass Object
(
[code] => 1001
[message] => Invalid request: invalid input : Invalid document details
)
Код: Выделить всё
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->apiRequest);
Код: Выделить всё
document: {"document": {"referenceId": "1234", "name": "LH2.PNG", "contentType": "image/png", "meta": { "imageType": "SIGNATURE","imageIndex": "IMAGE_1"}},"rules": {"workflowName": "LetterheadSignature" }}
attachment: file.PNG
Код: Выделить всё
$body = (object)[
'referenceId' => 'Signature',
'name' => $filename,
'contentType' => $filetype,
'rules' => (object)[
'workflowName' => 'LetterheadSignature',
],
'meta' => (object)[
'imageType' => 'SIGNATURE',
'imageIndex' => 'IMAGE_1',
]
];
$sent_data = [
'document' => json_encode($body),
'attachment' => $file,
];
$this->apiRequest = $sent_data;
Код: Выделить всё
$handle = fopen($full_filename, "r");
$file_contents = fread($handle, filesize($full_filename));
fclose($handle);
$file = base64_encode($file_contents);
Код: Выделить всё
$file = curl_file_create($full_filename, $filetype, $filename);
Код: Выделить всё
$filename = 'image-of-signature.png';
$filetype = 'image/png';
$full_filename = 'path-to-file' . $filename;
В документации FedEx параметр Attachment описывается как:
Код: Выделить всё
string
Input the actual document/file to be uploaded.
Подробнее здесь: https://stackoverflow.com/questions/787 ... age-upload
Мобильная версия