Revision 288c1d55

b/docs/source/devguide.rst
748 748
X-Object-Meta-Trash          Set to ``true`` if the object has been moved to the trash
749 749
X-Object-Meta-*              Use for other tags that apply to the object
750 750
===========================  ==============================
751

  
752
Recommended Practices and Examples
753
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
754

  
755
Assuming an authentication token is obtained (**TBD**), the following high-level operations are available - shown with ``curl``:
756

  
757
* Get account information ::
758

  
759
    curl -X HEAD -D - \
760
         -H "X-Auth-Token: 0000" \
761
         https://pithos.dev.grnet.gr/v1/user
762

  
763
* List available containers ::
764

  
765
    curl -X GET -D - \
766
         -H "X-Auth-Token: 0000" \
767
         https://pithos.dev.grnet.gr/v1/user
768

  
769
* Get container information ::
770

  
771
    curl -X HEAD -D - \
772
         -H "X-Auth-Token: 0000" \
773
         https://pithos.dev.grnet.gr/v1/user/pithos
774

  
775
* Add a new container ::
776

  
777
    curl -X PUT -D - \
778
         -H "X-Auth-Token: 0000" \
779
         https://pithos.dev.grnet.gr/v1/user/test
780

  
781
* Delete a container ::
782

  
783
    curl -X DELETE -D - \
784
         -H "X-Auth-Token: 0000" \
785
         https://pithos.dev.grnet.gr/v1/user/test
786

  
787
* List objects in a container ::
788

  
789
    curl -X GET -D - \
790
         -H "X-Auth-Token: 0000" \
791
         https://pithos.dev.grnet.gr/v1/user/pithos
792

  
793
* List objects in a container (extended reply) ::
794

  
795
    curl -X GET -D - \
796
         -H "X-Auth-Token: 0000" \
797
         https://pithos.dev.grnet.gr/v1/user/pithos?format=json
798

  
799
* List metadata keys used by objects in a container
800

  
801
  Will be in the ``X-Container-Object-Meta`` reply header, included in container information or object list (``HEAD`` or ``GET``).
802

  
803
* List objects in a container having a specific meta defined ::
804

  
805
    curl -X GET -D - \
806
         -H "X-Auth-Token: 0000" \
807
         https://pithos.dev.grnet.gr/v1/user/pithos?meta=trash
808

  
809
  This is the recommended way of tagging/retrieving objects in trash.
810

  
811
* Retrieve an object ::
812

  
813
    curl -X GET -D - \
814
         -H "X-Auth-Token: 0000" \
815
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
816

  
817
* Retrieve an object (specific ranges of data) ::
818

  
819
    curl -X GET -D - \
820
         -H "X-Auth-Token: 0000" \
821
         -H "Range: bytes=0-9" \
822
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
823

  
824
  This will return the first 10 bytes. To get the first 10, bytes 30-39 and the last 100 use ``Range: bytes=0-9,30-39,-100``.
825

  
826
* Add a new object (folder type) (**TBD**) ::
827

  
828
    curl -X PUT -D - \
829
         -H "X-Auth-Token: 0000" \
830
         -H "Content-Type: application/folder" \
831
         https://pithos.dev.grnet.gr/v1/user/pithos/folder
832

  
833
* Add a new object ::
834

  
835
    curl -X PUT -D - \
836
         -H "X-Auth-Token: 0000" \
837
         -H "Content-Type: text/plain" \
838
         -T EXAMPLE.txt
839
         https://pithos.dev.grnet.gr/v1/user/pithos/folder/EXAMPLE.txt
840

  
841
* Update an object ::
842

  
843
    curl -X POST -D - \
844
         -H "X-Auth-Token: 0000" \
845
         -H "Content-Length: 10" \
846
         -H "Content-Type: application/octet-stream" \
847
         -H "Content-Range: bytes 10-19/*" \
848
         -d "0123456789" \
849
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
850

  
851
  This will update bytes 10-19 with the data specified.
852

  
853
* Update an object (append) ::
854

  
855
    curl -X POST -D - \
856
         -H "X-Auth-Token: 0000" \
857
         -H "Content-Length: 10" \
858
         -H "Content-Type: application/octet-stream" \
859
         -H "Content-Range: bytes */*" \
860
         -d "0123456789" \
861
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
862

  
863
* Add object metadata ::
864

  
865
    curl -X POST -D - \
866
         -H "X-Auth-Token: 0000" \
867
         -H "X-Object-Meta-First: first_meta_value" \
868
         -H "X-Object-Meta-Second: second_meta_value" \
869
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
870

  
871
* Delete object metadata ::
872

  
873
    curl -X POST -D - \
874
         -H "X-Auth-Token: 0000" \
875
         -H "X-Object-Meta-First: first_meta_value" \
876
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
877

  
878
  Metadata can only be "set". To delete ``X-Object-Meta-Second``, reset all metadata.
879

  
880
* Delete an object ::
881

  
882
    curl -X DELETE -D - \
883
         -H "X-Auth-Token: 0000" \
884
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
885

  
b/pithos/api/functions.py
608 608
            raise ItemNotFound('Object does not exist')
609 609
    
610 610
    # A Content-Type or Content-Range header may indicate data updates.
611
    if content_type and content_type.startswith('multipart/byteranges'):
611
    if content_type is None:
612
        return HttpResponse(status=202)
613
    if content_type.startswith('multipart/byteranges'):
612 614
        # TODO: Support multiple update ranges.
613 615
        return HttpResponse(status=202)
614 616
    # Single range update. Range must be in Content-Range.
615 617
    # Based on: http://code.google.com/p/gears/wiki/ContentRangePostProposal
616 618
    # (with the addition that '*' is allowed for the range - will append).
617
    if content_type and content_type != 'application/octet-stream':
619
    if content_type != 'application/octet-stream':
618 620
        return HttpResponse(status=202)
619 621
    content_range = request.META.get('HTTP_CONTENT_RANGE')
620 622
    if not content_range:

Also available in: Unified diff