收藏
回答

bug:通过接口请求上传至微信云托管对象存储成功,但是无法显示图片?

https://developers.weixin.qq.com/miniprogram/dev/wxcloudrun/src/development/storage/service/upload.html


使用如下curl会上传失败

curl --location --request POST 'https://cos.ap-shanghai.myqcloud.com/6465-dev-9gzuacjfbb8d2165-1318321492/test/微信图片_20230304191918.jpg' \
--form 'file=@"C:\\Users\\ASUS\\Pictures\\微信图片_20230304191918.jpg"' \
--form 'Signature="q-sign-algorithm=sha1&q-ak=AKIDdGn8XoLG4xX-q-JOt50ZhdddVQvMplHTJvZy939JcNJfuSBIGFCGpVRtYgGdRUH1&q-sign-time=1684932106;1684933006&q-key-time=1684932106;1684933006&q-header-list=&q-url-param-list=&q-signature=37e0d20ddec88fc18f24364a23d8031924bb7d5a"' \
--form 'x-cos-security-token="AKg0kUmhA4uujNjwWbvhyTOcFGq6TRHa3ca997662d11cc801a1c991b713c4f8c_2-uybEdLAb0MSMN2apDhaPYJUUmpTCNZI07uLi8i8PsZEqCyoVDaAreduXA_cPs7EmlT9NWKxsmP1kW12QXZuv1lCwOhoYUQmP8ASHjErDrqOZe8Yn4tNyAinVLGgn52SYbF2AZd_Xn329ilQNUifNRbckIelmPiEDsoiuvAYBxP-34pmqXxB3z4XHTwMEsVX2cFEkgaw_waFyeFXfk-a_1B6MPXqfDoyp0EKb_gvE4wLQbYcZRjK1pk4Hind_16kZbiGL5UpqCvUSFwnkdVBe5EudQ11YT4OJh-SZKOmuruzYD6roGiVRFl7o3VO5D1blU6G_swNKnERzjJvqT_fKVuCI8l_1EmdN35CZN-4_2DaaW6IMy7VUAH5m8Prgs"' \
--form 'x-cos-meta-fileid="HGex33aHngZA+nnrg94iUa1mivg0M2IywfoWRoK1GXaRwgwLWmtG/Dibatxo/xhnpb+5aFyOMT60mx0i+vj5IoIRp8Y0+fHJWzGaqHS+d/8D22jm1OLICN07/e1p4BuDD+xf4ug3H4Ej3jp9p6qmpNF1BpFO4YtdP4sZJ6aPQFZNuZsBRwip/Ijt9i5eOSim4ZXJj5ezhJki6J0="' \
--form 'key="test/微信图片_20230304191918.jpg"'


报错信息为

<?xml version='1.0' encoding='utf-8' ?>

<Error>

    <Code>MalformedPOSTRequest</Code>

    <Message>The body of your POST request is not well-formed multipart/form-data.</Message>

    <Resource>/test/微信图片_20230304191918.jpg</Resource>

    <RequestId>NjQ2ZTA2MjlfN2VlOTgxZV8xNGQ2ZF8yNDQ4M2Q5</RequestId>

    <TraceId>OGVmYzZiMmQzYjA2OWNhODk0NTRkMTBiOWVmMDAxODc0OWRkZjk0ZDM1NmI1M2E2MTRlY2MzZDhmNmI5MWI1OTI5MWRkM2I1ZDU3ZWE5Y2YzNDYzZTEzY2JlMjU3NDQ0ZDcwYzUyN2FkYjcxMmFjNjg5MGY0OWIyZWRlNDFhMGQ=</TraceId>

</Error>



使用如下curl会上传成功,但是云托管中查看图片链接无法预览

curl --location --request POST 'https://cos.ap-shanghai.myqcloud.com/6465-dev-9gzuacjfbb8d2165-1318321492/test/微信图片_20230304191918.jpg' \
--form 'file="file://C:\\Users\\ASUS\\Pictures\\微信图片_20230304191918.jpg"' \
--form 'Signature="q-sign-algorithm=sha1&q-ak=AKIDdGn8XoLG4xX-q-JOt50ZhdddVQvMplHTJvZy939JcNJfuSBIGFCGpVRtYgGdRUH1&q-sign-time=1684931011;1684931911&q-key-time=1684931011;1684931911&q-header-list=&q-url-param-list=&q-signature=759af149895862780089488066ec1faf8c59d8ab"' \
--form 'x-cos-security-token="AKg0kUmhA4uujNjwWbvhyTOcFGq6TRHa3ca997662d11cc801a1c991b713c4f8c_2-uybEdLAb0MSMN2apDhaPYJUUmpTCNZI07uLi8i8PsZEqCyoVDaAreduXA_cPs7EmlT9NWKxsmP1kW12QXZuv1lCwOhoYUQmP8ASHjErDrqOZe8Yn4tNyAinVLGgn52SYbF2AZd_Xn329ilQNUifNRbckIelmPiEDsoiuvAYBxP-34pmqXxB3z4XHTwMEsVX2cFEkgaw_waFyeFXfk-a_1B6MPXqfDoyp0EKb_gvE4wLQbYcZRjK1pk4Hind_16kZbiGL5UpqCvUSFwnkdVBe5EudQ11YT4OJh-SZKOmuruzYD6roGiVRFl7o3VO5D1blU6G_swNKnERzjJvqT_fKVuCI8l_1EmdN35CZN-4_2DaaW6IMy7VUAH5m8Prgs"' \
--form 'x-cos-meta-fileid="HHZVSTCMAdIatMrSMG3yuYtfv03qbDL994CUocYGoeCTMKBXhBo6m7uES+ICALaSsLc7fCOW+jBVMYMQWyt5PMoznzcbeZsUiwlhezbp7y+s3Ri1Ceirog7ZXtMWSURxDVscejIjVXG+JrHz2AB0oS4GykMO9BOvFHRG9IMxB1KQYXtaPfIPH/aKVl+AlrcSkwAvMfCQgxCfRpw="' \
--form 'key="test/微信图片_20230304191918.jpg"'
回答关注问题邀请回答
收藏
登录 后发表内容