File size limit for upload/download
Hello, I would like to know if CACHE has any limitations on uploading files.
Why am I asking this, why am I going through a problem here.
What happens is that when uploading files or images that are larger than 2.7 MB CACHE is limiting the size to 2.7 MB, any file larger than that is saved corrupted.
Already at the time of uploading the file or image, CACHE is limiting the size of the file to 2.6 MB.
Caché does not have any such limitations, please provide more information (update you post), how you use to load files to Caché, and how you check size for saved file after that.
My guess is that you are passing data somewhere as a string (because that is around the string limit). You need to use streams instead to store the uploaded file.
Yes, we create a component in javaScript, it sends a CACHE function to the text file, the internal function created in CACHE, this text is converted to base 64, and then we save the text (url of the file) .
{
#dim id AS %String
#dim resposta AS %String = ""
#dim exception AS %Exception.AbstractException
#dim estimativa AS EstimativaPrecoVenda
try {
set id = ##class(%CSP.Page).Decrypt( idEncriptado )
if (..%ExistsId(id)){
set estimativa = ..%OpenId(id)
do estimativa.anexo.send(nomeArquivo, streamArquivo)
do estimativa.%Save()
set resposta = $$$OK
}
} catch exception {
set resposta = $$$FormatText("%1 - %2",exception.Name, exception.Data)
}
quit resposta
}
{
#dim stream As %FileBinaryStream
set stream = ##class(GlobalBinaryStreamUtil).convertDataStream( streamFile )
do ##class(GlobalBinaryStreamSpec).validateNameFile( nameFile )
do ##class(GlobalBinaryStreamSpec).validateExtensionFile( nameFile )
do ##class(GlobalBinaryStreamSpec).validateSizeFile( stream.Size )
do ..strnameSet( ##class(GlobalBinaryStreamUtil).sanitizeName(nameFile) )
do ..objfile.CopyFromAndSave( stream )
quit $$$OK
}
{
#dim stream As %FileBinaryStream
#dim text As %String
set stream = ##class(%FileBinaryStream).%New()
if ($isObject(streamFile)){
set text = streamFile.Read( streamFile.Size )
do stream.Write( ..convertTextPlain( text ) )
} else {
do stream.Write( ..convertTextPlain( streamFile ) )
}
quit stream
}
ClassMethod convertTextPlain(streamFile As %String) As %String [ Private ]
{
#dim textPlain As %String
#dim exception AS %Exception.AbstractException
try {
set textPlain = $SYSTEM.Encryption.Base64Decode(streamFile)
} catch exception {
if ( exception.Name = "<ILLEGAL VALUE>"){
set textPlain = streamFile
} else {
throw exception
}
}
quit textPlain
}
ClassMethod sanitizeName(nameFile As %String) As %String
{
quit $translate(nameFile," ","_")
}