问题
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.
- 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
- 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
- Construct the CDN url and return it to the client
来源:https://stackoverflow.com/questions/18487201/handling-file-uploads-with-restler