<br><br><div class="gmail_quote">On Tue, Jul 10, 2012 at 6:35 PM, Mona Wong <span dir="ltr"><<a href="mailto:mona@sdsc.edu" target="_blank">mona@sdsc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><br></div><span style="white-space:pre-wrap"> </span>I have some questions about uploading a file via the web api:<div><br></div><div><span style="white-space:pre-wrap"> </span>1. How do you hand the actual content to save/upload to Midas via either midas.item.create or midas.upload.perform?</div>
<div><br></div></div></blockquote><div><br></div><div>Items are placeholders or groupings of resources in Midas, but they are separate from actual files that are uploaded and stored in an item. Each Item has zero or more ItemRevisions, which are collections of actual files. Each ItemRevision has zero or more Bitstreams, where a Bitstream is an actual file that has been uploaded to Midas.</div>
<div><br></div><div>midas.item.create will simply create the item for you without any ItemRevisions in it, and return to you the item including the item id. If you call midas.upload.generatetoken with the newly created item id and the filename of the file you want to upload and you will get an uploadtoken, then call midas.upload.perform, passing in that item id and uploadtoken, and omitting the revision parameter, an ItemRevision will be created in that item, and your file that you are uploading will be added to that newly created ItemRevision as a Bitstream. midas.upload.perform must be a PUT or POST, and you can include the actual contents of the file to be uploaded as part of the PUT or POST request. How you get the contents of the uploaded file into your request depends on which client/library you are using.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div></div><div><span style="white-space:pre-wrap"> </span>2. If the filename already exists, will both midas.item.create and midas.upload.perform automatically create a new revision of that file in Midas?</div>
<div><br></div></div></blockquote><div><br></div><div>If you call midas.item.create and try to create an Item in a Folder where there is already an Item by that name, Midas will create a new Item in that folder with an incremented number.</div>
<div><br></div><div>E.g.:</div><div><br></div><div>Initial state: </div><div><br></div><div>-Folder 1 (with id 1)</div><div><br></div><div><br></div><div>api call to midas.item.create (parentid=1, name=my_item)</div><div>
<br></div><div>Resulting state:</div><div><br></div><div>-Folder 1</div><div>--my_item</div><div><br></div><div><div>api call to midas.item.create (parentid=1, name=my_item)</div></div><div><br></div><div>Resulting state:</div>
<div><br></div><div><div>-Folder 1</div><div>--my_item</div><div>--my_item (1)</div></div><div><br></div><div><div>api call to midas.item.create (parentid=1, name=my_item)</div></div><div><br></div><div><div>Resulting state:</div>
<div><br></div><div><div>-Folder 1</div><div>--my_item</div><div>--my_item (1)</div></div></div><div><div>--my_item (2)</div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div></div><div><span style="white-space:pre-wrap"> </span>3. What is the difference between midas.upload.perform and midas.item.create?</div><div><br></div></div></blockquote><div><br></div>
<div>item.create creates the actual Item, without any ItemRevision or Bitstreams. </div><div><br></div><div>upload.perform, if called without the revision parameter, will create a new ItemRevision in the Item, and create a new Bitstream with the contents of the request (the actual bytes of the file you are uploading), and add the Bitstream to this ItemRevision. </div>
<div><br></div><div>If you call upload.perform with a revision parameter that is numeric, the request will try to create a new Bitstream in the ItemRevision given by that revision number. </div><div><br></div><div>If you call upload.perform with a revision parameter of "head", the request will create a new Bitstream in the latest ItemRevision for that Item, creating an ItemRevision if none exist for that Item.</div>
<div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div></div><div><span style="white-space:pre-wrap"> </span>4. For midas.upload.generatetoken, the parameter "itemid" is a bit confusing...it says "parent item", is it really "folderid" and "parent folder"?</div>
<div><br></div></div></blockquote><div><br></div><div>The parameter itemid for upload.generatetoken is the id of the Item that you want to add the file to, as a Bitstream. </div><div><br></div><div>Note that you can pass in the md5 checksum of the file, and if Midas already has a Bitstream with this same checksum, Midas will create a new Bitstream for this file content in the latest ItemRevision (creating an ItemRevision if necessary) of the Item corresponding to the itemid param, and will not return an upload token to you in this case.</div>
<div><br></div><div><br></div><div>HTH,</div><div>Mike</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div></div><div>thanks,</div><div><span style="font-size:12px">Mona</span></div><div><span style="font-size:12px"><br></span></div><div><span style="font-size:12px">*********************************************</span></div>
<div><div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:auto;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<div> Mona Wong</div><div> Web & iPad Application Developer</div><div> San Diego Supercomputer Center</div><div><br></div><div> Believing we are in control is an</div><div> illusion that brings suffering.</div>
<div><div><div>*********************************************</div><div><span style="font-size:medium"><br></span></div></div></div></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div>
</span><br></div></span><br></span><br>
</div>
<br></div></div><br>_______________________________________________<br>
Midas mailing list<br>
<a href="mailto:Midas@public.kitware.com">Midas@public.kitware.com</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/midas" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/midas</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks,<br>Michael Grauer<br>R & D Engineer<br>Kitware, Inc.<br>919 969 6990 x322<br><br><br><br>