How to upload a PDF File to firebase that is already in memory

I have seen posts and read the docs on how to upload a file with a url reference to local disk, however, I cannot find anything about how to do this with a file in memory? The file is an array of pdfs. I take it I have to have some kind of URL reference to that file. Where would I URL reference a pdf in memory? Anybody know?

Edit:

I used this code from the Docs, however, I'm getting the following error for putData: Type of expression is ambiguous without more context Which I think means the constructor is not expecting a type of PDFDoc?

@IBAction func confirmUploadButtonTapped(_ sender: Any) {
        let uuid = UUID().uuidString
        // Create a root reference
        let storage = Storage.storage()
        
        // Create a storage reference from our storage service
        let storageRef = storage.reference()
        
        // Data in memory
        let data = Data()

        // Create a reference to the file you want to upload
        let pdfRef = storageRef.child("docRequest/" + uuid + "/" + ".pdf")

        // Upload the file to the path "images/rivers.jpg"
        let uploadTask = pdfRef.putData(pdfDocument, metadata: nil) { (metadata, error) in
          guard let metadata = metadata else {
            // Uh-oh, an error occurred!
            print(error)
            return
          }
          // Metadata contains file metadata such as size, content-type.
          let size = metadata.size
          // You can also access to download URL after upload.
          pdfRef.downloadURL { (url, error) in
            guard let downloadURL = url else {
              // Uh-oh, an error occurred!
                print(error)
              return
            }
          }
        }

1 answer