xtaomei 发表于 2016-7-25 17:38:01

LR如何判断上传的文件已存在

我用LR录制本地文件上传,会动态关联很多值,如:timestamp,filed,md5值等等,如果我想第二次在上传一模一样的文件,脚本报错,因为获取不到那些值了,所以我想问问大侠们,如何写个判断文件已经存在了。以下是代码:
web_url("fileupload.do",
                "URL=http://192.168.34.63/drive/fileupload.do?sid=&diskType=1",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://192.168.34.63/drive/m.do",
                "Snapshot=t13.inf",
                "Mode=HTML",
                EXTRARES,
                "Url=static/flash/assets/get_flash_player.gif", "Referer=http://192.168.34.63/drive/fileupload.do?sid=&diskType=1", ENDITEM,
                LAST);


        web_set_max_html_param_len("9999999");
        web_reg_save_param("ssoid",
"LB=\"ssoid\":\"",
"RB=\"",
"Search=All",
LAST);

        web_reg_save_param("print",
"LB=\"fingerPrint\":\"",
"RB=\"",
"Search=All",
LAST);

        web_reg_save_param("fileid",
"LB=\"fileId\":\"",
"RB=\"",
"Search=All",
LAST);

web_reg_save_param("timestamp",
"LB=\"timestamp\":\"",
"RB=\"",
"Search=All",
LAST);

web_reg_save_param("taskno",
"LB=\"taskNo\":\"",
"RB=\"",
"Search=All",
LAST);

web_reg_save_param("middleurl",
"LB=\"middleUrl\":\"",
"RB=\"",
"Search=All",
LAST);




        web_custom_request("file.do",
                "URL=http://192.168.34.63/drive/service/common/file.do?func=common:upload&rnd=0.7277041117971712,78",
                "Method=POST",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/javascript",
                "Referer=http://192.168.34.63/drive/m.do",
                "Snapshot=t14.inf",
                "Mode=HTML",
                "EncType=text/javascript; charset=utf-8",
                "Body={\"appFileId\":\"\",\"diskType\":1,\"uploadType\":2,\"creatorUsn\":\"\",\"parentid\":-1,\"groupId\":\"\",\"fileSize\":\"102400\",\"fileName\":\"{filedname}\",\"fileMd5\":\"{md5}\",\"comeFrom\":1,\"model\":0,\"discussContent\":\"\",\"security\":0}",
                LAST);




web_submit_data("fastuploadsvr.fcg",
                "Action=http://192.168.34.63:8082/fcgi-bin/fastuploadsvr.fcg",
                "Method=POST",
                "EncType=multipart/form-data",
                "TargetFrame=",
                "RecContentType=text/plain",
                "Referer=",
                "Snapshot=t15.inf",
                "Mode=HTML",
                ITEMDATA,
                "Name=cmd", "Value=114", ENDITEM,
                "Name=type", "Value=1", ENDITEM,
                "Name=version", "Value=100", ENDITEM,
                "Name=comefrom", "Value=1", ENDITEM,
                "Name=taskno", "Value={taskno}", ENDITEM,
                "Name=fileid", "Value={fileid}", ENDITEM,
                "Name=middleurl", "Value={middleurl}", ENDITEM,
                "Name=filesize", "Value=102400", ENDITEM,
                "Name=timestamp", "Value={timestamp}", ENDITEM,
                "Name=ssoid", "Value={ssoid}", ENDITEM,
                "Name=flowtype", "Value=0", ENDITEM,
                "Name=userlevel", "Value=1", ENDITEM,
                "Name=usernumber", "Value={username}", ENDITEM,
                "Name=filemd5", "Value={md5}", ENDITEM,
                "Name=filename", "Value={filedname}", ENDITEM,
                "Name=range", "Value=0-102399", ENDITEM,
                "Name=fingerprint", "Value={print}", ENDITEM,
                "Name=filedata", "Value=F://{filedname}", "File=Yes", ENDITEM,
                LAST);

       
        web_custom_request("search.do_4",
                "URL=http://192.168.34.63/drive/service/disk/search.do?func=disk:userInfo&rnd=0.0546339353186196,109",
                "Method=POST",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/javascript",
                "Referer=http://192.168.34.63/drive/m.do",
                "Snapshot=t16.inf",
                "Mode=HTML",
                "EncType=text/javascript; charset=utf-8",
                "Body={\"usn\":1515,\"diskType\":1}",
                LAST);

        web_custom_request("search.do_5",
                "URL=http://192.168.34.63/drive/service/disk/search.do?func=disk:search&rnd=0.8637553627453618,93",
                "Method=POST",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/javascript",
                "Referer=http://192.168.34.63/drive/m.do",
                "Snapshot=t17.inf",
                "Mode=HTML",
                "EncType=text/javascript; charset=utf-8",
                "Body={\"usn\":1515,\"IsNotCheckSub\":1,\"diskType\":1,\"parentId\":-2,\"status\":1,\"orderField\":\"create_date\",\"orderBy\":\"desc\",\"picThumbnail\":0,\"picWidth\":72,\"picHeight\":72}",
                LAST);

seagull1985 发表于 2016-7-26 09:50:11

上传一模一样的文件,如果报错,应该也是服务器端返回的报错或是js报错吧。。你脚本为什么要去判断这个东西,如果要判断感觉也应该拿服务器返回的报文去判断,自己写脚本判断没必要啊。。。

xtaomei 发表于 2016-7-26 10:17:08

seagull1985 发表于 2016-7-26 09:50
上传一模一样的文件,如果报错,应该也是服务器端返回的报错或是js报错吧。。你脚本为什么要去判断这个东西 ...

嗯,,是服务器返回的报错,附图,因为第二次上传相同文件的时候服务器会校验文件的md5值,如果发现md5相同就会变成秒传,那这些值:fileid,timestamp ,taskno等等就获取不到,服务器返回个OK值,我想问问这个地方应该怎样写个判断语句,谢谢了
页: [1]
查看完整版本: LR如何判断上传的文件已存在