title: How to save base64 encoded file in LoopBack within a hook
body: <p>I'm trying to find a way to save a file in a loopback application that was send as base64 encoded string.</p>
  
  <p>So I have a model with all possible field and also a base64 encoded image, “receipt”.</p>
  
  <pre><code>{
    ...modelData,
    "receipt": "datadata:image/jpeg;base64,whatever=="
  }
  </code></pre>
  
  <p>So... what I'm thinking of is this</p>
  
  <pre><code>Model.beforeRemote('create', function(ctx, model, next) {
    const file = ctx.args.data.receipt;
    app.models.Attachment.upload(...)
    // and replace base64 with returned filename
  })
  </code></pre>
  
  <p>But I don't clearly understand how and what should I pass to that upload method. Or maybe it has to be some different approach.</p>
  
  <p>Thanks!</p>