Hi,
If your assumption of using REST API is not really a need, then personnally
I would do things differently. I can just expose general idea, don't have
much time to go into details but maybe it can help you ...
- create a new specific page in XWiki (RemoteAttachmentService ?), that
will, using some parameters provided when targeting its url (url of remote
image, name of xwiki page to create attachment, filename of this
attachment), do the following:
- perform a GET on that url to retrieve image bytes (I think you can
find Groovy examples by looking at extensions about Jira or Nexus
integration on
xwiki.org for the GET), or to save that image as a temporary
file somewhere
- use XWiki API to create or update a new page, create a new Attachment
on this page and set the image bytes as its content, save that doc
- write some JSON as unique page content with info you like (result
success/failure, error message, whatever...)
- from the page where you want your users to add that sort of attachments,
perform an Ajax request on RemoteAttachmentService, with needed parameters,
and manage success/failure to display result to user
I assumed that you didn't want to reload the page (as you wanted to make it
in javascript), if you don't care you can use only what I called
RemoteAttachmentService as unique page, and don't bother with Ajax call, of
course.
BR,
Jeremie
2013/2/13 zacharykane <kane.zach(a)gmail.com>
I think I should maybe put this another way.
What I'm trying to do is add an attachment to a page that is a remotely
available image file. The way the process is desired to work is that the
user doesn't have to download this image and then use the attachment form
on
the page manually. Rather, they'd like to know if it can be taken care of
programmaticly.
I made an assumption of the REST API based upon the example of creating a
Page. It seems that this won't be the same process with creating files - at
least from a purely JavaScript perspective. Using Velocity can I achieve
something like this server side?
--
View this message in context:
http://xwiki.475771.n2.nabble.com/create-attachment-with-Rest-API-tp7583867…
Sent from the XWiki- Dev mailing list archive at
Nabble.com.
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs