2

Is it possible to upload an image file using AJAX to Domino Server? I am trying to upload a photo from Android phone. I can send the image data back to a rich text field in Domino. But I am not sure how to render it as an image on the Domino Form. Ideally I'd like to send the photo via ajax and have it attached to the Domino document as to a $File field.

The only example that is even close is here: http://markwambler.blogspot.com/2009/10/webcam-snapshots-and-lotusdomino.html

Thanks in advance. I have been struggling on this for days.

Ross
  • 2,079
  • 2
  • 22
  • 26
Mike B
  • 202
  • 3
  • 16
  • Are you actually getting the image attached and saved to the document? Are you wanting to display the resulting document and image in a browser or in the Notes client? – Kerr Jan 19 '11 at 17:09
  • I am able to send the data to a Rich-text field in the Notes Document. I'd like to display it via a Web Browser. I am pretty sure it is Base64 encoded. So how do I decode it and display as an image in the Domino Web Page? – Mike B Jan 19 '11 at 19:40

1 Answers1

2

So if you are able to send a Base64 encoded version to a rich text field and you want to display it via a browser then you have a couple of things to do.

  1. Make sure that you are creating your document using MIME.
  2. Create a MIME entity for the attachment.
  3. Populate the MIME entity with the Base64 string.
  4. Decode it into a regular file attachment on the document.

This will give you a regular Domino document with an attachment that you can create a URL and to link to.

This is essentially what the linked example code is doing. Namely:

session.ConvertMime=False
...
Set child = parent.CreateChildEntity()
Set header = child.CreateHeader("Content-Disposition")
Call header.SetHeaderVal({attachment; filename="} & fileName & {"})
...
Call child.SetContentFromText(stream, "image/jpeg", ENC_BASE64)
Call child.DecodeContent()

Once you have saved the document then it is trivial to arrange a link to the attachment url with something like db.nsf/viewname/dockey/$file/filename.jpg or put the url in an img src parameter.

Not having a set up to play with at the moment it's a little difficult to test. I also suspect it would be better if you could mimic a regular file upload from the client. In that case you would not need to mess about with Base64 and MIME with the 1.3x expansion over the wire that gives.

Kerr
  • 2,792
  • 21
  • 31
  • 1
    After hours of trial and error I finally got it to work! The Base64 image was not encoded correctly and needs to be fixed once it gets to Domino! – Mike B Jan 24 '11 at 22:14