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

Cannot display images correctly using manuallyAddFile() #474

Open
NeoTianHow opened this issue Jul 3, 2019 · 8 comments · May be fixed by #549
Open

Cannot display images correctly using manuallyAddFile() #474

NeoTianHow opened this issue Jul 3, 2019 · 8 comments · May be fixed by #549

Comments

@NeoTianHow
Copy link

NeoTianHow commented Jul 3, 2019

I am trying to display images using the manuallyAddFile() method. However, I could not display the images for some reason. Here are my codes: Do Note that I am passing in a base64URL Is that the cause of this issue?

 dropOptions: {
        url: "https://httpbin.org/post",
        acceptedFiles: "image/*",
        // maxFiles: 1,
        addRemoveLinks: true,
        autoProcessQueue: false,
        thumbnailWidth: 160,
        thumbnailHeight: 160
      }

setTimeout(() => {
          this.form.varient.files.forEach(eachFile => {
            var file = {
              size: eachFile.size,
              name: eachFile.name,
              type: eachFile.type
            };
            this.$refs.myVueDropzone.manuallyAddFile(file, eachFile.dataURL);
          });
        }, 0);

image

@NeoTianHow
Copy link
Author

@rowanwins

@NeoTianHow
Copy link
Author

@ndarilek @ejucovy @andrewharvey @keevitaja

@rowanwins
Copy link
Owner

Hi @NeoTianHow

Yes I suspect the base64url is the cause of the issue. If you look at these lines you will see that we attempt some basic validation before creating a thumbnail.

Also please don't tag people on issues unnecessarily - it is not their job (particularly if they aren't maintainers) to provide you with support within 15 minutes of the issue being posted.

@NeoTianHow
Copy link
Author

Hi, @rowanwins Thanks for the reply! I am sorry for tagging you, my apologies. If base64URL does not work, is there a way to display the image using a file object? Just to give you more context, whenever a user decides to upload a photo in the dropzone, I used the @vdropzone-file-added event listener to receive the user-upload file. I will then add the file into a list. Right now, I want to display the images whenever the user revisits the dropzone. I have the file object, how can I display it?

@vano20
Copy link

vano20 commented Aug 13, 2019

I have the same issues, Does my url wrongly submitted?

 let mockFile: any = {

      name: ${imageObject.id}_${

        imageObject.source

          .split('/')

          .pop()

          .split('#')[0]

          .split('?')[0]

      },

      id: imageObject.id,

      accepted: true,

      kind: 'image',

      status: 'fetched',

      type: 'image/jpeg',

      upload: {

        filename: imageObject.source

          .split('/')

          .pop()

          .split('#')[0]

          .split('?')[0]

      }

    }

    ;(this.$refs as any).images.manuallyAddFile(

      mockFile,

      imageObject.source // https://some.site/images/products/831621/5tKVv5j3LTXcogJhuMW8esO7nvktXMwoIvOYLvqM.png,

     () => {

        console.log('Callback')

      },

      null,

      {

        dontSubstractMaxFiles: true,

        addToFiles: true

      }

    )

  })

`

@vano20
Copy link

vano20 commented Aug 19, 2019

@NeoTianHow hey sorry for the tag as this issue likely not progressing.. Did you by any chance already solving this issue?

@nviitala
Copy link

nviitala commented Dec 4, 2019

In addition to extensions ("fileUrl.indexOf(".jpg")") user might need to supply files without extensions (eg. server side is rendering the image with permission checks) or as base64.

For me, I am using manuallyAddFile with type: "image/jpeg" and without file extension. Could the script just check if the defined type matches image/* or kind: 'image' or something like that - when there is no extension?

For now, I did solve it via manuallyAddFile(Object, /dynamic/filepath#.jpg) - with #.jpg it assumes it to be an image and server loads it as supposed.

@rowanwins rowanwins linked a pull request May 9, 2020 that will close this issue
8 tasks
@rowanwins
Copy link
Owner

Being worked on in #549

@rowanwins rowanwins added this to the v3.7 milestone May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants