Skip to content

Question about input sources loading #4

Description

@Salmondx

I was trying to debug why my example stuck on processing and found this code in library sources:

/**
 * Retrieve the URL and type of a media source
 * @param {string|RawSource} source
 */
const getMetadata = async (page, id, source) => {
  let data
  let type
  if (typeof source === 'string') {
    // Source is a path. Read into a new buffer.
    data = fs.readFileSync(source, 'base64')
    const extension = source.substring(source.indexOf('.') + 1)
    type = mime.getType(extension)
  } else {
    // Source is an object of the form {type: string, data: Buffer}
    data = source.data.toString('base64')
    type = source.type
  }
  // Prepend base64 header
  url = `data:${type};base64,${data}`
  return { url, type }
}

As I can see files are just loaded as base64 strings to memory, correct? So it is not possible to use etro-node with large files or multiple input sources?

Thanks in advance!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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