Skip to content

Inconsistant json reading in Dropbox #1343

@jonocodes

Description

@jonocodes

I am writing a bunch of different file types. Some are html, some are json. All the content is stored as a string in the "body" param like so:

{
    "revision": "0163ca314dab8fe00000002d8598cd3",
    "timestamp": 1755520987607,
    "contentType": "application/json",
    "body": '{
        "state": "unread",
        "publication": null,
        "publishedDate": "2024-09-24T20:00:00.000Z",
        "ingestPlatform": "typescript/web (0.5.0)",
        "ingestSource": "url",
        "mimeType": "text/html",
        "readTimeMinutes": 2,
        "progress": 0
    }'
}

When I fetch any file, the body comes back as text and then I parse it. This has been the case for the RemoteStorage connector at least.

I noticed that when using the DropBox connector however, it reading a json file, the body comes back as JSON. This is inconsistent. So here is what my code looks like.

      const file = (await client.getFile(path)) as { data: string };
      console.log("data", file.data);

      // If file.data is already an object, use it directly as the article
      if (typeof file.data === "object") {
        // for some reason this only happens with dropbox storage?
        articles.push(file.data as Article);
      } else {
        const article: Article = JSON.parse(file.data);
        articles.push(article);
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions