📣 The forum has moved to GitHub

We’ve switched to GitHub Discussions as the hub for our community. This will improve the experience of collaborating for everyone, sharing what you’re working on, and discussing ideas for how Swell can be improved. Existing threads will remain open, but new posts are disabled.

Go to GitHub →

Bug: Unable to upload pdf using data key.

 var pdf = fs.readFileSync("/Users/yyy/Downloads/xxx.pdf, { encoding: "base64" });
 
var r = await swell.put('/accounts/xxxx', {
    content : {
      proof_of_business: {
        file : {
          content_type: "application/pdf",
          filename: "some file.pdf",
            data: { 
              $binary: pdf, 
              $type: "00" 
          }
       }
    }
  }

This does not work. Error

Error: Object fields contain "$" or "." and are not valid for storage. (cmd: "update", query: {"query":{"_id”:”xxx”},”update":{"$set":{"content":{"proof_of_business":{"id”:”xxx”,”length":31,"date_uploaded":"2022-06-22T06:16:47.588Z","content_type":"binary/octet-stream","md5”:”yyy”,”url":"https://cdn.schema.io/yyy”,”file":{"content_type":"application/pdf","filename":"some file.pdf","url":"file:////Users/yyy/Downloads/xxx”.pdf,”data":{"$binary":"JVBERi0xLjMKJeLjz9….

Comments

  • Addendum:

    Upon upload, the field looks like the following in Swell entity


    If one tries to download and open it, it appears as


  • Hi @Onwo

    I think the $binary field should have as a value the pdf content transformed to base64, like this:

    {

    content_type: 'application/pdf',

    filename: 'some-file.pdf',

    data: {

    '$binary': based64_pdf_content

    }

    }

Sign In or Register to comment.