Question
· Nov 10, 2016

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.

Discussion (3)0
Log in or sign up to continue

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) .

 

ClassMethod enviarAnexo(idEncriptado As %String, nomeArquivo As %String, streamArquivo As %CSP.CharacterStream) As %String
{
    #dim id AS %String
    #dim resposta AS %String ""
    #dim exception AS %Exception.AbstractException
    #dim estimativa AS EstimativaPrecoVenda    

    try {
        set id ##class(%CSP.Page).DecryptidEncriptado )        
        if (..%ExistsId(id)){
            set estimativa =  ..%OpenId(id)            
             do estimativa.anexo.send(nomeArquivostreamArquivo)            
             do estimativa.%Save()
            set resposta $$$OK
        }
    catch exception {
        set resposta $$$FormatText("%1 - %2",exception.Nameexception.Data)
    }
    
    quit resposta
}

 

Method send(nameFile As %String, streamFile As %CSP.CharacterStream) As %Status
{
    #dim stream As %FileBinaryStream    
    set stream ##class(GlobalBinaryStreamUtil).convertDataStreamstreamFile )
    
    do ##class(GlobalBinaryStreamSpec).validateNameFilenameFile )
    do ##class(GlobalBinaryStreamSpec).validateExtensionFilenameFile )
    do ##class(GlobalBinaryStreamSpec).validateSizeFilestream.Size )
    
    do ..strnameSet##class(GlobalBinaryStreamUtil).sanitizeName(nameFile)
    do ..objfile.CopyFromAndSavestream )
    
    quit $$$OK
}

ClassMethod convertDataStream(streamFile As %CSP.CharacterStream) As %FileBinaryStream
{
    #dim stream As %FileBinaryStream
    #dim text As %String
    
    set stream  ##class(%FileBinaryStream).%New()
    if ($isObject(streamFile)){        
        set text streamFile.ReadstreamFile.Size )
        do stream.Write..convertTextPlaintext )
    else {
        do stream.Write..convertTextPlainstreamFile )
    }
    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," ","_")
}