使用Restler处理文件上传 [英] Handling file uploads with Restler

查看:163
本文介绍了使用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.

  1. UploadFormat添加到受支持的格式
  2. 调整UploadFormat的静态属性以适合您的需求
  3. 通过api方法使用$_FILESmove_uploaded_file将文件获取到所需的文件夹.此步骤在任何php上传过程中都很常见.
  1. add UploadFormat to the supported formats
  2. Adjust the static properties of UploadFormat to suit your need
  3. From your api method use $_FILES and move_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

  1. 将其上传到CDN.您可以使用CDN提供的任何方式.可以是ftp或使用某些SDK进行上传
  2. 构造CDN网址并将其返回给客户端

这篇关于使用Restler处理文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆