Hi,
I need to open a file, read the contents, and convert to a byte array.
I have tried:
read the file from disk that will be attached to the page
f = File.new(“file.jpg”, “r”)
contents = f.read
java_bytes = contents.to_java_bytes
puts “java_bytes is of type #{java_bytes.class}”
gives: “java_bytes is of type #Class:01x41c977” - not right?
I now need to pass java_bytes, and other args, to the method below
[from
Confluence API]
addAttachment(String token, long contentId,
Attachmenthttp://confluence.atlassian.com/display/DOC/Remote+API+Specification#RemoteAPISpecification-Attachment
attachment,
byte[] attachmentData)
newattachment = service.addAttachment(@sid, ‘40932323’, attachment,
java_bytes)
However, the service.addAttachment line gives the error:
“… no addAttachment with arguments matching [class java.lang.String,
class java.lang.String, class
com.sun.dse.wikis.remote.stub.RemoteAttachment, class [B] on object
JavaUtilities (NameError) …”
Error looks as if it’s with the 4th arg - the byte[]. I’ve used
to_java_bytes to convert the file to a binary array, but it doesn’t look
right.
Any thoughts?
Thanks,
~mm