如何使用loopback api explorer上传文件?

时间:2021-08-25 11:12:55

I'm using loopback Api Explorer I need to upload a file by explore how can I upload that because I don't find any option to upload file please refer the screenshot

我正在使用loopback Api Explorer我需要通过探索上传文件如何上传,因为我没有找到任何上传文件的选项请参考截图

如何使用loopback api explorer上传文件?.

3 个解决方案

#1


3  

Simply put, the answer is that you can't. Uploading a file requires multi-part form data. This isn't currently possible via the loopback-component-explorer. You should checkout the loobpack-component-storage instead. There is an example here; I recommend using the example-2.0.

简单地说,答案就是你做不到。上传文件需要多部分表单数据。目前无法通过loopback-component-explorer实现。你应该检查loobpack-component-storage。这里有一个例子;我建议使用示例-2.0。

#2


1  

You can test it with something like POSTMAN.

您可以使用POSTMAN之类的东西进行测试。

But, the only that you need, is the path of the file, not the file.

但是,唯一需要的是文件的路径,而不是文件。

#3


0  

Simpler than using Postman would be using curl direct on the terminal :

比使用Postman更简单的是在终端上直接使用curl:

Here is the command I use when need(I work with some services using loopback/explorer as well) :

这是我在需要时使用的命令(我也使用loopback / explorer处理一些服务):

curl -i -X POST -H "Content-Type: multipart/form-data" -F "blob=@/path/to/your/file.jpg" -v http://HOST:PORT/pathToYourEndpoint?access_token=xxxxxxxxxxx

curl -i -X POST -H“Content-Type:multipart / form-data”-F“blob =@/path/to/your/file.jpg”-v http:// HOST:PORT / pathToYourEndpoint?access_token = XXXXXXXXXXX

#1


3  

Simply put, the answer is that you can't. Uploading a file requires multi-part form data. This isn't currently possible via the loopback-component-explorer. You should checkout the loobpack-component-storage instead. There is an example here; I recommend using the example-2.0.

简单地说,答案就是你做不到。上传文件需要多部分表单数据。目前无法通过loopback-component-explorer实现。你应该检查loobpack-component-storage。这里有一个例子;我建议使用示例-2.0。

#2


1  

You can test it with something like POSTMAN.

您可以使用POSTMAN之类的东西进行测试。

But, the only that you need, is the path of the file, not the file.

但是,唯一需要的是文件的路径,而不是文件。

#3


0  

Simpler than using Postman would be using curl direct on the terminal :

比使用Postman更简单的是在终端上直接使用curl:

Here is the command I use when need(I work with some services using loopback/explorer as well) :

这是我在需要时使用的命令(我也使用loopback / explorer处理一些服务):

curl -i -X POST -H "Content-Type: multipart/form-data" -F "blob=@/path/to/your/file.jpg" -v http://HOST:PORT/pathToYourEndpoint?access_token=xxxxxxxxxxx

curl -i -X POST -H“Content-Type:multipart / form-data”-F“blob =@/path/to/your/file.jpg”-v http:// HOST:PORT / pathToYourEndpoint?access_token = XXXXXXXXXXX