【发布时间】:2021-05-15 14:25:11
【问题描述】:
我尝试使用 Shopware 6 API 使用带有 WinHttp.WinHttpRequest.5.1 的 VBA 将东西从现有的 Access 数据库迁移到新商店。除媒体传输外,一切正常。
我的做法:
- 在右侧媒体文件夹的商店软件中创建媒体对象
POST /api/v3/media
payload: "{""mediaFolderId"":""" & folderID & """,""id"":""ec90cae2cc84c37b6b7a0cb9fe5c4548""}"
工作正常!
- 通过url上传新图片(testfile.png)
POST /api/v3/_action/media/ec90cae2cc84c37b6b7a0cb9fe5c4548/upload?extension=png&fileName=testfile
payload: "{""url"":"" & MediaUrl & "." & MediaUrlExt & ""}"
response 204 (no error),
创建了一个媒体文件,但文件的内容不是PNG图像而是负载字符串。
VBA 代码:
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
AuthURL = url & "/api/v2/_action/media/" & newMediaID & "/upload?extension=" & FileExtFromUrl(MediaUrl) & "&fileName=" & FileNameFromUrl(MediaUrl) & "&_response=true"
objHTTP.Open "POST", AuthURL, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.setRequestHeader "Content-type", "application/json"
objHTTP.setRequestHeader "Accept", "application/json"
objHTTP.setRequestHeader "Authorization", "Bearer " & Token
Debug.Print AuthURL
payload = "{""url"":""https://" & FTPUrl & ftpKategorieOrdner & "/" & MediaUrl & """}"
Debug.Print payload
objHTTP.send (payload)
strResult = objHTTP.responseText
Debug.Print strResult
Debug.Print "uploadMedia " & objHTTP.Status; " - " + objHTTP.StatusText
也许创建缩略图是个问题?开发日志:
[2021-05-18 15:13:22] messenger.INFO: Sending message Shopware\Core\Content\Media\Message\GenerateThumbnailsMessage with Enqueue\MessengerAdapter\QueueInteropTransport {"message":"[object] (Shopware\\Core\\Content\\Media\\Message\\GenerateThumbnailsMessage: {})","class":"Shopware\\Core\\Content\\Media\\Message\\GenerateThumbnailsMessage","sender":"Enqueue\\MessengerAdapter\\QueueInteropTransport"} []
[2021-05-18 15:13:23] php.INFO: User Deprecated: The "Symfony\Component\Debug\DebugClassLoader" class is deprecated since Symfony 4.4, use "Symfony\Component\ErrorHandler\DebugClassLoader" instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"Symfony\\Component\\Debug\\DebugClassLoader\" class is deprecated since Symfony 4.4, use \"Symfony\\Component\\ErrorHandler\\DebugClassLoader\" instead. at ./vendor/symfony/debug/DebugClassLoader.php:16)"} []
怎么了?
【问题讨论】:
-
这不是重复的 - uw ms 尝试通过 URL 上传图像(因此 Shopware 下载图像并将其插入到库中) - 链接的问题会发布图像数据。
标签: vba api ms-access media shopware