dapr / js-sdk

Dapr SDK for Javascript
Apache License 2.0
192 stars 80 forks source link

Cannot get binary files when using the azure blob storage binding #597

Closed marto83 closed 7 hours ago

marto83 commented 2 months ago

Expected Behavior

Using the following code I would except to either receive a buffer or a base64 encoded string.

const result = await client.binding.send('filestore', 'get', null,  { blobName: filename });
    console.log(typeof result); // string
    const buffer = Buffer.from(result, 'base64'); 

Actual Behavior

What you actually get is a mangled string that is a binary stream converted to text and then parsed as JSON.

Steps to Reproduce the Problem

  1. Create a bindings.azure.blobstorage binding and set decodeBase64 to true.
  2. Upload a file where data is a Buffer

    const base64Data = data.toString('base64');
    const meta = {
      blobName: fileName,
      "contentType"        : contentType ?? 'application/octet-stream',
      "contentDisposition" : "attachment",
      "cacheControl"       : "no-cache",
      "custom"             : "hello-world"
    };
    
    const response = await client.binding.send(Bindings.fileStore, 'create', base64Data, meta);
  3. Get the file back and save it to disk
dapr-bot commented 1 week ago

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot commented 7 hours ago

This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.