Differential / meteor-uploader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uploads the same image every time unless server restarts or page reload

opened this issue · comments

Hi,

I encountered this weird bug that every time I pick a single random picture to upload, the package uploads the first one I picked since last server restart or page reload.

I followed your tutorial in README, and included CamanJS as a <script> tag in the <head>.

This is not a big issue for me right now, but I'd love to get some insights from you. Thank you.

Here is the example repo: https://github.com/boilingApps/uploader-example

OK. I have narrowed the issue down to CamanJS integration, i.e.:

manipulateImage: (dataURL, fileInfo, upload) ->
  img = new Image()
  img.onload = ->
    Caman @, ->
      @resize height: 100
      @render ->
        upload @canvas.toDataURL(fileInfo.type)
  img.src = dataURL

If I comment out this section, the upload works as expected. If I include the above section, the uploaded picture will always be the one I uploaded the first time, unless I reload the page.

I tried include the CamanJS source code in the client folder, or in the <head> tag, it doesn't matter.

Sweet, I'll look at it a little closer. I'm in the process of reworking a
few other pieces of this package now anyway. Thanks
On Sep 24, 2014 7:47 PM, "Huang Yu" notifications@github.com wrote:

OK. I have narrowed the issue down to CamanJS integration, i.e.:

manipulateImage: (dataURL, fileInfo, upload) ->
img = new Image()
img.onload = ->
Caman @, ->
@resize height: 100
@render ->
upload @canvas.toDataURL(fileInfo.type)
img.src = dataURL

If I comment out this section, the upload works as expected. If I include
the above section, the uploaded picture will always be the one I uploaded
the first time, unless I reload the page.

I tried include the CamanJS source code in the client folder, or in the

tag, it doesn't matter.


Reply to this email directly or view it on GitHub
#4 (comment)
.

Hi @schnie,

Thanks for your reply. I still havn't figured out a way to solve it. Have to move on to other area of dev for now.

I see your last commit was 28 days ago, so could you tell me when are you going to release the next version? Thanks

Want to take a look at this issue @zerokewl177 ?

Thank you so much.

I found out that Caman @, -> takes whatever image and throw out the first ever image when the first time Caman initialized, that is, unless I reload the page, which will reset Caman.

I know this is now beyond the scope of this package, but I'd love to get your insights while I'm reporting this to CamanJS repository.

OK. I just solved the issue.

caman = null

...

if caman?
  caman.loadImage @, ->
    @resize height: 100
    @render ->
      upload @canvas.toDataURL(fileInfo.type)
else
  caman = Caman @, ->
    @resize height: 100
    @render ->
      upload @canvas.toDataURL(fileInfo.type)