为什么要转BASE64,体积暴涨三分之一,明显直取更快,200MB文件对单个文件来说,不算大。
赵总还写了啥直读程序,
于是就来验证一下情况
拿出猫框,简单的操作一下
建立MSSQL数据库表
1生成猫框DAL类
Define Class Dal_myfile As Qiyu_CursorAdapter Of Locfile('Qiyu_CursorAdapter.fxp')
*--创建:祺佑工作室 日期:2023.09.20 http://www.sn58.cn
Alias = 'myfile'
WhereType = 1 && 1 关键字段 2 关键字段And可更新字段 3关键字段及其它已修改的字段 4 关键字段And时间戳
KeyFieldList = "ID"
Tables = "myfile"
oDAL=.F.
nRecno=0
uId=.f.
uOldId=.f.
DataSourceType="ODBC"
BufferModeOverride= 5 && 3 开放式行缓冲 5开放式表缓冲
isUpdateDelcmd=.t. &&执行DELETE方法后,是否立即更新后台数据库
FetchSize=-1
InsertCmdRefreshFieldList='ID'
UpdateCmdRefreshFieldList='ID'
InsertCmdRefreshCmd='SELECT ID FROM myfile WHERE ID=@@IDENTITY'
PROCEDURE setupCA
Text to This.SelectCmd noshow
select TOP 1 ID,MYIMG from myfile ORDER BY id desc
EndText
Text to This.CursorSchema noshow
ID I(4) , MYimg w(4)
EndText
Text to This.UpdatableFieldList noshow
ID,MYIMG
EndText
Text to This.UpdateNameList noshow
ID myfile.ID,MYIMG myfile.MYIMG
EndText
ENDPROC
Procedure Init
LPARAMETERS nCon,uId
DoDefault(nCon)
this.setupCA() &&初始各个字段
Endproc
Procedure New
This.nRecno=recno(this.alias)
this.add()
Endproc
Procedure Edit
Lparameters cName
this.nRecno=recno(this.alias)
ENDPROC
*--由子类实现
Procedure Go
Note:接收一个uId的参数,并刷新表内容 注意未决更新会导致刷新失败
Lparameters uId
Endproc
*--勾子方法,删除之前执行
Procedure OnBeforeDelete()
Endproc
*--勾子方法,删除之后执行
Procedure OnAfterDelete()
Endproc
*--勾子方法,保存之后执行
Procedure OnAfterSave
Endproc
*--勾子方法,保存之前执行
Procedure OnBeforeSave
Endproc
Procedure OnAfterUndo()
NOTE *--勾子方法,撤消之后执行
select (this.alias)
locate for this.nRecno=recno()
Endproc
Procedure FieldValid
NOTE:勾子方法,定位到修改记录行,自行判断
Endproc
PROCEDURE parsejson
LPARAMETERS cJson,cRoot,naction,cKeylist
LOCAL oReader,cField,nFieldState
oReader=Newobject("QiyuJsonReader","QiyuJsonReader.prg") &&JSON序列类
oReader.cursorstruct=this.CursorSchema
oReader.Alias=this.alias &&临时表名
oReader.root=cRoot &&JSON数组所在位置 目前只支持第一层
oReader.keylist=this.KeyFieldList &&主键字段所在位置
oReader.parsecursor(cJson,naction) &&生成一个spaces表
IF !this.CursorAttach(this.alias,.t.)
AERROR(laerror)
this.msg=laerror(2)
RETURN .f.
ELSE
RETURN .t.
endif
Endproc
Enddefine
2 上传代码
xx=Getfile()
If !File(xx)
Return
Endif
nsec=Datetime()
yy=Filetostr(xx)
oDal_myfile =Newobject("Dal_myfile","Dal_myfile.prg")
oDal_myfile.Nodata=.T.
oDal_myfile.CursorFill(.T.)
oDal_myfile.new()
Replace myimg With yy
If !oDal_myfile.Save()
?oDal_myfile.msg
Endif
?"上传时间",Datetime()-nsec
3 从后端数据库的保存到本地的代码
oDal_myfile =NEWOBJECT("Dal_myfile","Dal_myfile.prg")
oDal_myfile.cursorfill(.t.)
copy memo myimg to 1.rar
472mb文件上传成功,下载成功,可以成功解压RAR文件。验证完毕。
SO EASY的猫框。
VFP文档中写W字段最大2G。
那突破也是有其它的方法,比如流式读写,上64位VFP。
无人区需要大家一起努力。