Handling file uploads with Restler

廉价感情. 提交于 2019-12-11 04:48:10

问题


What is the best practice to implement file uploads using Restler framework?

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?


回答1:


File upload to CDN using our API

This requires two steps, first is to get the file on the API server.

  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. Upload it to CDN. You can use any means provided my your CDN. It can be ftp or using some SDK to do the upload
  2. Construct the CDN url and return it to the client


来源:https://stackoverflow.com/questions/18487201/handling-file-uploads-with-restler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!