[Midas] question about uploading file via web api
Michael Grauer
michael.grauer at kitware.com
Wed Jul 11 11:12:34 EDT 2012
On Tue, Jul 10, 2012 at 6:35 PM, Mona Wong <mona at sdsc.edu> wrote:
>
> I have some questions about uploading a file via the web api:
>
> 1. How do you hand the actual content to save/upload to Midas via either
> midas.item.create or midas.upload.perform?
>
>
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.
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.
> 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?
>
>
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.
E.g.:
Initial state:
-Folder 1 (with id 1)
api call to midas.item.create (parentid=1, name=my_item)
Resulting state:
-Folder 1
--my_item
api call to midas.item.create (parentid=1, name=my_item)
Resulting state:
-Folder 1
--my_item
--my_item (1)
api call to midas.item.create (parentid=1, name=my_item)
Resulting state:
-Folder 1
--my_item
--my_item (1)
--my_item (2)
> 3. What is the difference between midas.upload.perform and
> midas.item.create?
>
>
item.create creates the actual Item, without any ItemRevision or
Bitstreams.
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.
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.
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.
> 4. For midas.upload.generatetoken, the parameter "itemid" is a bit
> confusing...it says "parent item", is it really "folderid" and "parent
> folder"?
>
>
The parameter itemid for upload.generatetoken is the id of the Item that
you want to add the file to, as a Bitstream.
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.
HTH,
Mike
> thanks,
> Mona
>
> *********************************************
> Mona Wong
> Web & iPad Application Developer
> San Diego Supercomputer Center
>
> Believing we are in control is an
> illusion that brings suffering.
> *********************************************
>
>
>
>
>
>
> _______________________________________________
> Midas mailing list
> Midas at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/midas
>
>
--
Thanks,
Michael Grauer
R & D Engineer
Kitware, Inc.
919 969 6990 x322
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/midas/attachments/20120711/21a8ff75/attachment.html>
More information about the Midas
mailing list