Skip to content

Consider adding base64 option to parseAs property. #2413

@vaiwa

Description

@vaiwa

Description

currently have similar code:

const {
    data: screenshotBlob,
    isLoading,
    error,
  } = api.useQuery('get', '/screenshot/{ctMmId}/{time}', {
    params: { path: { ctMmId: id, time: timestamp } },
    parseAs: 'blob',
  });

  const screenshotFile = useMemo(
    () =>
      screenshotBlob
        ? new File([screenshotBlob], 'screenshot.jpg', { type: 'image/jpeg' })
        : undefined,
    [screenshotBlob]
  );

  const screenshotBase64 = useBase64FromFile(screenshotFile);

and would like to hear if you would consider adding something like base64 option to the parseAs prop

so the with this new option my code could be much cleaner:

const {
    data: screenshotBase64,
    isLoading,
    error,
  } = api.useQuery('get', '/screenshot/{ctMmId}/{time}', {
    params: { path: { ctMmId: id, time: timestamp } },
    parseAs: 'base64',
  });

Proposal

Consider adding base64 option to parseAs property, which will do the conversion and instead of Blob will return to base64 string?

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions