使用Restler处理文件上传 [英] Handling file uploads with Restler
本文介绍了使用Restler处理文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Restler框架实现文件上传的最佳实践是什么?
What is the best practice to implement file uploads using Restler framework?
我喜欢进行API调用,以将文件保存在CDN中,然后将CDN文件URL返回给调用者.实施它的最佳方法是什么?
I like to have a API call that get the file save it in CDN and return back the CDN file URL to the caller. What is the best way to implement it?
推荐答案
使用我们的API将文件上传到CDN
这需要两个步骤,第一步是在API服务器上获取文件.
File upload to CDN using our API
This requires two steps, first is to get the file on the API server.
- 将
UploadFormat
添加到受支持的格式 - 调整
UploadFormat
的静态属性以适合您的需求 - 通过api方法使用
$_FILES
和move_uploaded_file
将文件获取到所需的文件夹.此步骤在任何php上传过程中都很常见.
- add
UploadFormat
to the supported formats - Adjust the static properties of
UploadFormat
to suit your need - From your api method use
$_FILES
andmove_uploaded_file
to get the file to the desired folder. This step is common for any php upload process.
现在您已将文件保存在服务器上
Now that you have the file on the server
- 将其上传到CDN.您可以使用CDN提供的任何方式.可以是ftp或使用某些SDK进行上传
- 构造CDN网址并将其返回给客户端
这篇关于使用Restler处理文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文