Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation enhancement] demonstrate a way to upload a local file in js #1959

Open
3aluw opened this issue Sep 10, 2023 · 1 comment
Open

Comments

@3aluw
Copy link

3aluw commented Sep 10, 2023

The JS examples on uploading a file aren't coherent, and they don't provide a clue for the most important use case (which is uploading local files)
the upload example gives a way to upload a simple inline SVG

  file: {
      'en-US': {
        contentType: 'image/svg+xml',
        fileName: 'circle.svg',
        file: '<svg><path fill="red" d="M50 50h150v50H50z"/></svg>'
      }

creating an asset example shows how to create an asset based on a url :

  file: {
      'en-US': {
        contentType: 'image/jpeg',
        fileName: 'example.jpeg',
        upload: 'https://example.com/example.jpg'
      }

Although direct uploads are supported since 2017 (as I guess) there is no example on the documentation, This causes some confusion as in this post or on stack overflow

@hnrq
Copy link

hnrq commented Feb 29, 2024

I don't have a single clue on how to upload a local image. There is an example using the Plain API, but the file just hangs in processing forever. I have tried sending a Buffer, sending a fs.readFileSync().toString(), or even the new ArrayBuffer(file.length)` thing (Which doesn't make sense to me, even though it's what's in the example). How can I upload an image using this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants