Skip to content

上传商户提交资料文件

商户在提交资料时,可通过本接口上传所需的文件

请求参数类型描述
sub_mchidstring子商户号
bodyobjectmultipart/form-data 数据结构
submission_fileobject要上传的资料文件
metastring媒体文件元信息,使用JSON表示
file_namestring商户上传的媒体图片的名称
file_digeststring图片文件的sha256摘要
item_idnumber资料项唯一id
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/filea.jpg');
$media->setMeta(\json_encode([
  'file_name' => 'filea.jpg',
  'file_digest' => 'B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9',
  'item_id' => 56
]));

$instance->v3->mchManage->submissionFiles->subMchid->_sub_mchid_->upload->postAsync([
  'sub_mchid' => '123000110',
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/filea.jpg');
$media->setMeta(\json_encode([
  'file_name' => 'filea.jpg',
  'file_digest' => 'B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9',
  'item_id' => 56
]));

$instance->chain('v3/mch-manage/submission-files/sub-mchid/{sub_mchid}/upload')->postAsync([
  'sub_mchid' => '123000110',
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/filea.jpg');
$media->setMeta(\json_encode([
  'file_name' => 'filea.jpg',
  'file_digest' => 'B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9',
  'item_id' => 56
]));

$instance['v3/mch-manage/submission-files/sub-mchid/{sub_mchid}/upload']->postAsync([
  'sub_mchid' => '123000110',
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/filea.jpg');
$media->setMeta(\json_encode([
  'file_name' => 'filea.jpg',
  'file_digest' => 'B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9',
  'item_id' => 56
]));

$response = $instance->v3->mchManage->submissionFiles->subMchid->_sub_mchid_->upload->post([
  'sub_mchid' => '123000110',
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/filea.jpg');
$media->setMeta(\json_encode([
  'file_name' => 'filea.jpg',
  'file_digest' => 'B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9',
  'item_id' => 56
]));

$response = $instance->chain('v3/mch-manage/submission-files/sub-mchid/{sub_mchid}/upload')->post([
  'sub_mchid' => '123000110',
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/filea.jpg');
$media->setMeta(\json_encode([
  'file_name' => 'filea.jpg',
  'file_digest' => 'B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9',
  'item_id' => 56
]));

$response = $instance['v3/mch-manage/submission-files/sub-mchid/{sub_mchid}/upload']->post([
  'sub_mchid' => '123000110',
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
file_idstring文件标识ID

参阅 官方文档

Published on the GitHub by TheNorthMemory