---+!! =paraworld.map.UploadFile= <div style="float: right; margin: 5px; width: 250px; color: #4e5155; background-color: #f0eded; border: #ccc 1px solid; padding: 5px"> *Contents* %TOC% </div> ---++ Description 上传文件。<br/> 每次上传操作最多只能上传不大于1M的文件,对于大于1M的文件,需要分成多次进行上传。<br/> 对于图像图片的上传(即需要生成缩略图的用户图像),<b>总文件大小不能大于1M</b><br/> 若要将一个文件分成多次进行上传,则必须提供totalByte参数,并且值必须大于0,<b>第一次上传成功后会返回一个filePath节点(若在第一次上传时提供了filePath参数,则此返回值即提供的filePath参数),在其后的每次上传中都必须提供此参数</b>。<br/> 若 fromByte == 0 && fromByte + 当前上传数据的二进制数组的长度 == totalByte,则会将此次上传操作视为非分批上传,即将一个文件一次性上传完成。 ---++ Parameters |*Required*|*Name*|*Type*|*Description*| |<font color="#4682b4">required</font>|sessionKey|%BLUE%string%ENDCOLOR%|用户凭证。上传文件时必须登录| |^|file|%BLUE%string%ENDCOLOR%|文件数据二进制的base64编码| |<font color="4682b4">optional</font>|isPhoto|%BLUE%boolean%ENDCOLOR%|是否是图片,如果是,则会生成一个原图(原图最大宽度若大于256,则会适度缩小)和一个小图,默认值为false| |^|isHeadPic|%BLUE%boolean%ENDCOLOR%|是否是用户图像,如果该值为true,则isPhoto必须为true,默认值为false| |^|fromByte|%BLUE%long%ENDCOLOR%|此次上传的数据在整个文件的二进制数组中的起始位置,当分多次上传一个文件时,若非第一次上传,则必须有fromByte、totalByte、filePath参数| |^|totalByte|%BLUE%long%ENDCOLOR%|上传文件的二进制数组的总大小,如果isPhoto==true,则totalByte不可大于1024*1024| |^|extension|%BLUE%string%ENDCOLOR%|文件的后缀名,如(.jpg .txt 等,若未提供,则从参数filePath中获取,若extension和filepPath都没有值,则没有后缀名)| |^|filePath|%BLUE%string%ENDCOLOR%|逻辑路径。若未指定,则会默认为 “upload/[当前日期]/[随机文件名][后缀名]”| |^|overwrite|%BLUE%int%ENDCOLOR%|若指定的目录中已存在同名的文件,是否覆盖它(即删除旧文件,保存新文件),0:否,1:是。如果为0,当指定目录中已存在同名的文件时,会返回错误码:410| |^|format|%BLUE%int%ENDCOLOR%|返回的数据格式(0:XML 1:JSON),默认值为0| ---++ Example Return XML 当将一个文件分成多次上传时,<b>非最后一次</b>返回: <verbatim> <msg xmlns=""> <fileSize type="string">200000</fileSize> <filePath type="string">upload/2008-8-25/34bf7b12-3b14-4510-ae71-8e5b9e92ecac.jpg</filePath> </msg> </verbatim> 最后一次返回: <verbatim> <msg xmlns=""> <fileSize type="string">648704</fileSize> <fileURL type="string">http://api.pala5.com:81/Uploads/UserUpload/2008-8-25/e85cf3ca-eaf4-4bcd-b3a2-4ee02a12d4dc.jpg</fileURL> <fileCRC type="string">1665963060</fileSrc32> <filePath type="string">upload/2008-8-25/34bf7b12-3b14-4510-ae71-8e5b9e92ecac.jpg</filePath> </msg> </verbatim> 若所传参数中isPhoto==true,即所传文件是一个用户图像,则会生成一个缩略图,返回值中会有此缩略图的URL: <verbatim> <fileURL_Small type="string">http://api.pala5.com:81/Uploads/UserUpload/Small/890c79da-4201-4da1-9c52-a77a1ca408cd.jpg</fileURL_Small> </verbatim> ---++ Example Return JSON <verbatim> {"fileURL":"http:\/\/localhost:1630\/Uploads\/UserUpload\/2008-12-8\/1e0a5342-83d7-4c12-9973-974b9d1f67c4.jpg", "filePath":"\/cyf\/test2","fileSize":"96463","fileCrc32":"1106263707"} </verbatim> ---++ Error Codes 当发生异常时,返回数据中会有一个“errorCode”节点,该节点记录了错误码。0:无异常 500:未知错误 499:提供的数据不完整 498:非法的访问 497:数据不存在或已被删除 496:未登录 查看完整的[[ErrorCodes][Error Code]] ---++ Test Cases ---+++!! case 1 Input: <verbatim> { ["filePath"]="map/test.jpg", ["file"]="R0lGODlhBwAJAIABAAAzzP///yH5BAEAAAEALAAAAAAHAAkAAAIMjI+Am9yhoDRRVnoKADs=", ["extension"]=".jpg", ["sessionKey"]="fae5feb1-9d4f-4a78-843a-1710992d4e00", } </verbatim> _Result_: <verbatim> { ["fileCRC"]="4279738660", ["fileURL"]="http://192.168.0.221:81/Uploads/UserUpload/2008-5-7/a373295b-aecc-47d4-bc59-50ba00289602.jpg", } </verbatim>
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r11
<
r10
<
r9
<
r8
<
r7
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r11 - 2009-01-04
-
CaoYF
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback