shlogg · Early preview
Ramu Narasinga @karthik-m22

How Documenso Stores Uploaded Files In Its Database

Uploaded file stored as string in database after base64 encoding and conversion to Uint8Array.

In this article, we analyse how Documenso stores an uploaded file into its database by reviewing its source code. Where is this code that does this? You will find the below code snippet in a file named upload/put-file.ts.


const putFileInDatabase = async (file: File) => {
  const contents = await file.arrayBuffer();
  const binaryData = new Uint8Array(contents);
  const asciiData = base64.encode(binaryData);
  return {
    type: DocumentDataType.BYTES_64,
    data: asciiData,
  };
};

    
    

    
    




  
  
  arrayBuffer

So what exactly is happening here? contents is assigned a value...