我试图建立一个网站,将存储大量的图像。我正在使用的存储API模块,它是通过web很好地工作。
现在我需要一个REST服务来上传图片。我正在尝试使用服务模块的默认文件POST端点:
--> POST http://example.com/api/file http/1.1
Content-Type: application/json
Content-Length: 343901
Cookie: ..............
X-Csrf-Token: .........
{"file":"iVBOR.......Jggg==","filename":"myimage.png","uri":"storage-field-images://myimage.png"}
--> END POST (343901-byte body)
<-- 200 OK http://example.com/api/file (888ms)
Content-Type: application/json
{"fid":"81","uri":"http://example.com/api/file/81"}
<-- END HTTP (74-byte body)但http://example.com/api/file/81在回应我:
{"fid":"81","filename":"myimage.png","uri":"public://myimage.png".........(与我在请求中发送的uri不同)
我在寻找中遗漏了什么吗?或者我需要开发一个新的端点来管理它呢?
发布于 2020-07-16 10:11:29
将uri替换为filepath
--> POST http://example.com/api/file http/1.1
Content-Type: application/json
Content-Length: 343901
Cookie: ..............
X-Csrf-Token: .........
{"file":"iVBOR.......Jggg==","filename":"myimage.png","filepath":"public://storage-field-images/myimage.png"}
--> END POST (343901-byte body)https://drupal.stackexchange.com/questions/286866
复制相似问题