fog-internet-archive 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +53 -0
  3. data/.travis.yml +16 -0
  4. data/Gemfile +3 -0
  5. data/README.md +6 -0
  6. data/Rakefile +19 -0
  7. data/fog-internet-archive.gemspec +32 -0
  8. data/lib/fog/bin/internet_archive.rb +32 -0
  9. data/lib/fog/internet_archive.rb +1 -0
  10. data/lib/fog/internet_archive/core.rb +291 -0
  11. data/lib/fog/internet_archive/models/storage/directories.rb +39 -0
  12. data/lib/fog/internet_archive/models/storage/directory.rb +105 -0
  13. data/lib/fog/internet_archive/models/storage/file.rb +254 -0
  14. data/lib/fog/internet_archive/models/storage/files.rb +119 -0
  15. data/lib/fog/internet_archive/models/storage/ia_attributes.rb +36 -0
  16. data/lib/fog/internet_archive/parsers/storage/access_control_list.rb +42 -0
  17. data/lib/fog/internet_archive/parsers/storage/complete_multipart_upload.rb +20 -0
  18. data/lib/fog/internet_archive/parsers/storage/copy_object.rb +18 -0
  19. data/lib/fog/internet_archive/parsers/storage/cors_configuration.rb +38 -0
  20. data/lib/fog/internet_archive/parsers/storage/delete_multiple_objects.rb +45 -0
  21. data/lib/fog/internet_archive/parsers/storage/get_bucket.rb +58 -0
  22. data/lib/fog/internet_archive/parsers/storage/get_bucket_lifecycle.rb +64 -0
  23. data/lib/fog/internet_archive/parsers/storage/get_bucket_location.rb +16 -0
  24. data/lib/fog/internet_archive/parsers/storage/get_bucket_logging.rb +36 -0
  25. data/lib/fog/internet_archive/parsers/storage/get_bucket_website.rb +22 -0
  26. data/lib/fog/internet_archive/parsers/storage/get_request_payment.rb +16 -0
  27. data/lib/fog/internet_archive/parsers/storage/get_service.rb +28 -0
  28. data/lib/fog/internet_archive/parsers/storage/initiate_multipart_upload.rb +20 -0
  29. data/lib/fog/internet_archive/parsers/storage/list_multipart_uploads.rb +52 -0
  30. data/lib/fog/internet_archive/parsers/storage/list_parts.rb +36 -0
  31. data/lib/fog/internet_archive/requests/storage/abort_multipart_upload.rb +27 -0
  32. data/lib/fog/internet_archive/requests/storage/acl_utils.rb +60 -0
  33. data/lib/fog/internet_archive/requests/storage/complete_multipart_upload.rb +46 -0
  34. data/lib/fog/internet_archive/requests/storage/copy_object.rb +77 -0
  35. data/lib/fog/internet_archive/requests/storage/cors_utils.rb +39 -0
  36. data/lib/fog/internet_archive/requests/storage/delete_bucket.rb +42 -0
  37. data/lib/fog/internet_archive/requests/storage/delete_bucket_cors.rb +26 -0
  38. data/lib/fog/internet_archive/requests/storage/delete_bucket_lifecycle.rb +26 -0
  39. data/lib/fog/internet_archive/requests/storage/delete_bucket_policy.rb +26 -0
  40. data/lib/fog/internet_archive/requests/storage/delete_bucket_website.rb +26 -0
  41. data/lib/fog/internet_archive/requests/storage/delete_multiple_objects.rb +88 -0
  42. data/lib/fog/internet_archive/requests/storage/delete_object.rb +46 -0
  43. data/lib/fog/internet_archive/requests/storage/get_bucket.rb +108 -0
  44. data/lib/fog/internet_archive/requests/storage/get_bucket_acl.rb +65 -0
  45. data/lib/fog/internet_archive/requests/storage/get_bucket_cors.rb +61 -0
  46. data/lib/fog/internet_archive/requests/storage/get_bucket_lifecycle.rb +35 -0
  47. data/lib/fog/internet_archive/requests/storage/get_bucket_location.rb +54 -0
  48. data/lib/fog/internet_archive/requests/storage/get_bucket_logging.rb +45 -0
  49. data/lib/fog/internet_archive/requests/storage/get_bucket_policy.rb +31 -0
  50. data/lib/fog/internet_archive/requests/storage/get_bucket_website.rb +38 -0
  51. data/lib/fog/internet_archive/requests/storage/get_object.rb +163 -0
  52. data/lib/fog/internet_archive/requests/storage/get_object_acl.rb +72 -0
  53. data/lib/fog/internet_archive/requests/storage/get_object_http_url.rb +48 -0
  54. data/lib/fog/internet_archive/requests/storage/get_object_https_url.rb +30 -0
  55. data/lib/fog/internet_archive/requests/storage/get_object_torrent.rb +45 -0
  56. data/lib/fog/internet_archive/requests/storage/get_object_url.rb +49 -0
  57. data/lib/fog/internet_archive/requests/storage/get_request_payment.rb +45 -0
  58. data/lib/fog/internet_archive/requests/storage/get_service.rb +50 -0
  59. data/lib/fog/internet_archive/requests/storage/head_object.rb +57 -0
  60. data/lib/fog/internet_archive/requests/storage/initiate_multipart_upload.rb +42 -0
  61. data/lib/fog/internet_archive/requests/storage/list_multipart_uploads.rb +52 -0
  62. data/lib/fog/internet_archive/requests/storage/list_parts.rb +53 -0
  63. data/lib/fog/internet_archive/requests/storage/post_object_hidden_fields.rb +36 -0
  64. data/lib/fog/internet_archive/requests/storage/put_bucket.rb +70 -0
  65. data/lib/fog/internet_archive/requests/storage/put_bucket_acl.rb +69 -0
  66. data/lib/fog/internet_archive/requests/storage/put_bucket_cors.rb +47 -0
  67. data/lib/fog/internet_archive/requests/storage/put_bucket_lifecycle.rb +76 -0
  68. data/lib/fog/internet_archive/requests/storage/put_bucket_logging.rb +79 -0
  69. data/lib/fog/internet_archive/requests/storage/put_bucket_policy.rb +25 -0
  70. data/lib/fog/internet_archive/requests/storage/put_bucket_website.rb +59 -0
  71. data/lib/fog/internet_archive/requests/storage/put_object.rb +94 -0
  72. data/lib/fog/internet_archive/requests/storage/put_object_acl.rb +73 -0
  73. data/lib/fog/internet_archive/requests/storage/put_object_url.rb +43 -0
  74. data/lib/fog/internet_archive/requests/storage/put_request_payment.rb +45 -0
  75. data/lib/fog/internet_archive/requests/storage/sync_clock.rb +24 -0
  76. data/lib/fog/internet_archive/requests/storage/upload_part.rb +39 -0
  77. data/lib/fog/internet_archive/signaturev4.rb +71 -0
  78. data/lib/fog/internet_archive/storage.rb +381 -0
  79. data/lib/fog/internet_archive/version.rb +5 -0
  80. data/tasks/bundler.rake +3 -0
  81. data/tasks/console.rake +17 -0
  82. data/tasks/lint.rake +3 -0
  83. data/tasks/test.rake +7 -0
  84. data/tests/helper.rb +36 -0
  85. data/tests/helpers/collection_helper.rb +88 -0
  86. data/tests/helpers/formats_helper.rb +98 -0
  87. data/tests/helpers/formats_helper_tests.rb +106 -0
  88. data/tests/helpers/mock_helper.rb +13 -0
  89. data/tests/helpers/model_helper.rb +29 -0
  90. data/tests/helpers/responds_to_helper.rb +11 -0
  91. data/tests/helpers/schema_validator_tests.rb +101 -0
  92. data/tests/helpers/succeeds_helper.rb +9 -0
  93. data/tests/internet_archive/models/storage/directory_tests.rb +42 -0
  94. data/tests/internet_archive/models/storage/file_tests.rb +61 -0
  95. data/tests/internet_archive/models/storage/files_tests.rb +60 -0
  96. data/tests/internet_archive/models/storage/url_tests.rb +28 -0
  97. data/tests/internet_archive/requests/storage/acl_utils_tests.rb +209 -0
  98. data/tests/internet_archive/requests/storage/bucket_tests.rb +324 -0
  99. data/tests/internet_archive/requests/storage/cors_utils_tests.rb +108 -0
  100. data/tests/internet_archive/requests/storage/multipart_upload_tests.rb +132 -0
  101. data/tests/internet_archive/requests/storage/object_tests.rb +166 -0
  102. data/tests/internet_archive/signaturev4_tests.rb +41 -0
  103. data/tests/internet_archive/signed_params_tests.rb +5 -0
  104. data/tests/lorem.txt +1 -0
  105. metadata +322 -0
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ module GetObjectHttpsUrl
5
+ def get_object_https_url(bucket_name, object_name, expires, options = {})
6
+ get_object_url(bucket_name, object_name, expires, options.merge(:scheme => 'https'))
7
+ end
8
+ end
9
+
10
+ class Real
11
+ # Get an expiring object https url from S3
12
+ #
13
+ # @param bucket_name [String] Name of bucket containing object
14
+ # @param object_name [String] Name of object to get expiring url for
15
+ # @param expires [Time] An expiry time for this url
16
+ #
17
+ # @return [Excon::Response] response:
18
+ # * body [String] - url for object
19
+ #
20
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/dev/S3_QSAuth.html
21
+
22
+ include GetObjectHttpsUrl
23
+ end
24
+
25
+ class Mock # :nodoc:all
26
+ include GetObjectHttpsUrl
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ class Real
5
+ # Get torrent for an S3 object
6
+ #
7
+ # @param bucket_name [String] name of bucket containing object
8
+ # @param object_name [String] name of object to get torrent for
9
+ #
10
+ # @return [Excon::Response] response:
11
+ # * body [Hash]:
12
+ # * AccessControlPolicy [Hash:
13
+ # * Owner [Hash]:
14
+ # * DisplayName [String] - Display name of object owner
15
+ # * ID [String] - Id of object owner
16
+ # * AccessControlList [Array]:
17
+ # * Grant [Hash]:
18
+ # * Grantee [Hash]:
19
+ # * DisplayName [String] - Display name of grantee
20
+ # * ID [String] - Id of grantee
21
+ # * Permission [String] - Permission, in [FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP]
22
+ #
23
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGETtorrent.html
24
+
25
+ def get_object_torrent(bucket_name, object_name)
26
+ unless bucket_name
27
+ raise ArgumentError.new('bucket_name is required')
28
+ end
29
+ unless object_name
30
+ raise ArgumentError.new('object_name is required')
31
+ end
32
+ request({
33
+ :expects => 200,
34
+ :headers => {},
35
+ :host => "#{bucket_name}.#{@host}",
36
+ :idempotent => true,
37
+ :method => 'GET',
38
+ :path => CGI.escape(object_name),
39
+ :query => {'torrent' => nil}
40
+ })
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ module GetObjectUrl
5
+ def get_object_url(bucket_name, object_name, expires, options = {})
6
+ unless bucket_name
7
+ raise ArgumentError.new('bucket_name is required')
8
+ end
9
+ unless object_name
10
+ raise ArgumentError.new('object_name is required')
11
+ end
12
+ host, path = if bucket_name =~ Fog::InternetArchive::COMPLIANT_BUCKET_NAMES
13
+ ["#{bucket_name}.#{@host}", object_name]
14
+ else
15
+ [@host, "#{bucket_name}/#{object_name}"]
16
+ end
17
+ scheme_host_path_query({
18
+ :scheme => options[:scheme],
19
+ :headers => {},
20
+ :host => host,
21
+ :port => @port,
22
+ :method => 'GET',
23
+ :path => path,
24
+ :query => options[:query]
25
+ }, expires)
26
+ end
27
+ end
28
+
29
+ class Real
30
+ # Get an expiring object url from S3
31
+ #
32
+ # @param bucket_name [String] Name of bucket containing object
33
+ # @param object_name [String] Name of object to get expiring url for
34
+ # @param expires [Time] An expiry time for this url
35
+ #
36
+ # @return [Excon::Response] response:
37
+ # * body [String] - url for object
38
+ #
39
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/dev/S3_QSAuth.html
40
+
41
+ include GetObjectUrl
42
+ end
43
+
44
+ class Mock # :nodoc:all
45
+ include GetObjectUrl
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ class Real
5
+ require 'fog/internet_archive/parsers/storage/get_request_payment'
6
+
7
+ # Get configured payer for an S3 bucket
8
+ #
9
+ # @param bucket_name [String] name of bucket to get payer for
10
+ #
11
+ # @return [Excon::Response] response:
12
+ # * body [Hash]:
13
+ # * Payer [String] - Specifies who pays for download and requests
14
+ #
15
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTrequestPaymentGET.html
16
+
17
+ def get_request_payment(bucket_name)
18
+ request({
19
+ :expects => 200,
20
+ :headers => {},
21
+ :host => "#{bucket_name}.#{@host}",
22
+ :idempotent => true,
23
+ :method => 'GET',
24
+ :parser => Fog::Parsers::Storage::InternetArchive::GetRequestPayment.new,
25
+ :query => {'requestPayment' => nil}
26
+ })
27
+ end
28
+ end
29
+
30
+ class Mock # :nodoc:all
31
+ def get_request_payment(bucket_name)
32
+ response = Excon::Response.new
33
+ if bucket = self.data[:buckets][bucket_name]
34
+ response.status = 200
35
+ response.body = { 'Payer' => bucket['Payer'] }
36
+ else
37
+ response.status = 404
38
+ raise(Excon::Errors.status_error({:expects => 200}, response))
39
+ end
40
+ response
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ class Real
5
+ require 'fog/internet_archive/parsers/storage/get_service'
6
+
7
+ # List information about S3 buckets for authorized user
8
+ #
9
+ # @return [Excon::Response] response:
10
+ # * body [Hash]:
11
+ # * Buckets [Hash]:
12
+ # * Name [String] - Name of bucket
13
+ # * CreationTime [Time] - Timestamp of bucket creation
14
+ # * Owner [Hash]:
15
+ # * DisplayName [String] - Display name of bucket owner
16
+ # * ID [String] - Id of bucket owner
17
+ #
18
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTServiceGET.html
19
+ #
20
+ def get_service
21
+ request({
22
+ :expects => 200,
23
+ :headers => {},
24
+ :host => @host,
25
+ :idempotent => true,
26
+ :method => 'GET',
27
+ :parser => Fog::Parsers::Storage::InternetArchive::GetService.new
28
+ })
29
+ end
30
+ end
31
+
32
+ class Mock # :nodoc:all
33
+ def get_service
34
+ response = Excon::Response.new
35
+ response.headers['Status'] = 200
36
+ buckets = self.data[:buckets].values.map do |bucket|
37
+ bucket.reject do |key, value|
38
+ !['CreationDate', 'Name'].include?(key)
39
+ end
40
+ end
41
+ response.body = {
42
+ 'Buckets' => buckets,
43
+ 'Owner' => { 'DisplayName' => 'owner', 'ID' => 'some_id'}
44
+ }
45
+ response
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,57 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ class Real
5
+ # Get headers for an object from S3
6
+ #
7
+ # @param bucket_name [String] Name of bucket to read from
8
+ # @param object_name [String] Name of object to read
9
+ # @param options [Hash]:
10
+ # @option options [String] If-Match Returns object only if its etag matches this value, otherwise returns 412 (Precondition Failed).
11
+ # @option options [Time] If-Modified-Since Returns object only if it has been modified since this time, otherwise returns 304 (Not Modified).
12
+ # @option options [String] If-None-Match Returns object only if its etag differs from this value, otherwise returns 304 (Not Modified)
13
+ # @option options [Time] If-Unmodified-Since Returns object only if it has not been modified since this time, otherwise returns 412 (Precodition Failed).
14
+ # @option options [String] Range Range of object to download
15
+ #
16
+ # @return [Excon::Response] response:
17
+ # * body [String] Contents of object
18
+ # * headers [Hash]:
19
+ # * Content-Length [String] - Size of object contents
20
+ # * Content-Type [String] - MIME type of object
21
+ # * ETag [String] - Etag of object
22
+ # * Last-Modified - [String] Last modified timestamp for object
23
+ #
24
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectHEAD.html
25
+ #
26
+ def head_object(bucket_name, object_name, options={})
27
+ unless bucket_name
28
+ raise ArgumentError.new('bucket_name is required')
29
+ end
30
+ unless object_name
31
+ raise ArgumentError.new('object_name is required')
32
+ end
33
+ headers = {}
34
+ headers['If-Modified-Since'] = Fog::Time.at(options['If-Modified-Since'].to_i).to_date_header if options['If-Modified-Since']
35
+ headers['If-Unmodified-Since'] = Fog::Time.at(options['If-Unmodified-Since'].to_i).to_date_header if options['If-Modified-Since']
36
+ headers.merge!(options)
37
+ request({
38
+ :expects => 200,
39
+ :headers => headers,
40
+ :host => "#{bucket_name}.#{@host}",
41
+ :idempotent => true,
42
+ :method => 'HEAD',
43
+ :path => CGI.escape(object_name)
44
+ })
45
+ end
46
+ end
47
+
48
+ class Mock # :nodoc:all
49
+ def head_object(bucket_name, object_name, options = {})
50
+ response = get_object(bucket_name, object_name, options)
51
+ response.body = nil
52
+ response
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ class Real
5
+ require 'fog/internet_archive/parsers/storage/initiate_multipart_upload'
6
+
7
+ # Initiate a multipart upload to an S3 bucket
8
+ #
9
+ # @param bucket_name [String] Name of bucket to create object in
10
+ # @param object_name [String] Name of object to create
11
+ # @param options [Hash]:
12
+ # @option options [String] Cache-Control Caching behaviour
13
+ # @option options [String] Content-Disposition Presentational information for the object
14
+ # @option options [String] Content-Encoding Encoding of object data
15
+ # @option options [String] Content-MD5 Base64 encoded 128-bit MD5 digest of message (defaults to Base64 encoded MD5 of object.read)
16
+ # @option options [String] Content-Type Standard MIME type describing contents (defaults to MIME::Types.of.first)
17
+ # @option options [String] x-amz-acl Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
18
+ # @option options [String] x-amz-meta-#{name} Headers to be returned with object, note total size of request without body must be less than 8 KB.
19
+ #
20
+ # @return [Excon::Response] response:
21
+ # * body [Hash]:
22
+ # * Bucket [String] - Bucket where upload was initiated
23
+ # * Key [String] - Object key where the upload was initiated
24
+ # * UploadId [String] - Id for initiated multipart upload
25
+ #
26
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadInitiate.html
27
+ #
28
+ def initiate_multipart_upload(bucket_name, object_name, options = {})
29
+ request({
30
+ :expects => 200,
31
+ :headers => options,
32
+ :host => "#{bucket_name}.#{@host}",
33
+ :method => 'POST',
34
+ :parser => Fog::Parsers::Storage::InternetArchive::InitiateMultipartUpload.new,
35
+ :path => CGI.escape(object_name),
36
+ :query => {'uploads' => nil}
37
+ })
38
+ end
39
+ end # Real
40
+ end # Storage
41
+ end # InternetArchive
42
+ end # Fog
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ class Real
5
+ require 'fog/internet_archive/parsers/storage/list_multipart_uploads'
6
+
7
+ # List multipart uploads for a bucket
8
+ #
9
+ # @param [String] bucket_name Name of bucket to list multipart uploads for
10
+ # @param [Hash] options config arguments for list. Defaults to {}.
11
+ # @option options [String] key-marker limits parts to only those that appear lexicographically after this key.
12
+ # @option options [Integer] max-uploads limits number of uploads returned
13
+ # @option options [String] upload-id-marker limits uploads to only those that appear lexicographically after this upload id.
14
+ #
15
+ # @return [Excon::Response] response:
16
+ # * body [Hash]:
17
+ # * Bucket [string] Bucket where the multipart upload was initiated
18
+ # * IsTruncated [Boolean] Whether or not the listing is truncated
19
+ # * KeyMarker [String] first key in list, only upload ids after this lexographically will appear
20
+ # * MaxUploads [Integer] Maximum results to return
21
+ # * NextKeyMarker [String] last key in list, for further pagination
22
+ # * NextUploadIdMarker [String] last key in list, for further pagination
23
+ # * Upload [Hash]:
24
+ # * Initiated [Time] Time when upload was initiated
25
+ # * Initiator [Hash]:
26
+ # * DisplayName [String] Display name of upload initiator
27
+ # * ID [String] Id of upload initiator
28
+ # * Key [String] Key where multipart upload was initiated
29
+ # * Owner [Hash]:
30
+ # * DisplayName [String] Display name of upload owner
31
+ # * ID [String] Id of upload owner
32
+ # * StorageClass [String] Storage class of object
33
+ # * UploadId [String] upload id of upload containing part
34
+ # * UploadIdMarker [String] first key in list, only upload ids after this lexographically will appear
35
+ #
36
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadListMPUpload.html
37
+ #
38
+ def list_multipart_uploads(bucket_name, options = {})
39
+ request({
40
+ :expects => 200,
41
+ :headers => {},
42
+ :host => "#{bucket_name}.#{@host}",
43
+ :idempotent => true,
44
+ :method => 'GET',
45
+ :parser => Fog::Parsers::Storage::InternetArchive::ListMultipartUploads.new,
46
+ :query => options.merge!({'uploads' => nil})
47
+ })
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,53 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ class Real
5
+ require 'fog/internet_archive/parsers/storage/list_parts'
6
+
7
+ # List parts for a multipart upload
8
+ #
9
+ # @param bucket_name [String] Name of bucket to list parts for
10
+ # @param object_name [String] Name of object to list parts for
11
+ # @param upload_id [String] upload id to list objects for
12
+ # @param options [Hash] config arguments for list. Defaults to {}.
13
+ # @option options max-parts [Integer] limits number of parts returned
14
+ # @option options part-number-marker [String] limits parts to only those that appear lexicographically after this part number.
15
+ #
16
+ # @return [Excon::Response] response:
17
+ # * body [Hash]:
18
+ # * Bucket [string] Bucket where the multipart upload was initiated
19
+ # * Initiator [Hash]:
20
+ # * DisplayName [String] Display name of upload initiator
21
+ # * ID [String] Id of upload initiator
22
+ # * IsTruncated [Boolean] Whether or not the listing is truncated
23
+ # * Key [String] Key where multipart upload was initiated
24
+ # * MaxParts [String] maximum number of replies alllowed in response
25
+ # * NextPartNumberMarker [String] last item in list, for further pagination
26
+ # * Part [Array]:
27
+ # * ETag [String] ETag of part
28
+ # * LastModified [Timestamp] Last modified for part
29
+ # * PartNumber [String] Part number for part
30
+ # * Size [Integer] Size of part
31
+ # * PartNumberMarker [String] Part number after which listing begins
32
+ # * StorageClass [String] Storage class of object
33
+ # * UploadId [String] upload id of upload containing part
34
+ #
35
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadListParts.html
36
+ #
37
+ def list_parts(bucket_name, object_name, upload_id, options = {})
38
+ options['uploadId'] = upload_id
39
+ request({
40
+ :expects => 200,
41
+ :headers => {},
42
+ :host => "#{bucket_name}.#{@host}",
43
+ :idempotent => true,
44
+ :method => 'GET',
45
+ :parser => Fog::Parsers::Storage::InternetArchive::ListParts.new,
46
+ :path => CGI.escape(object_name),
47
+ :query => options.merge!({'uploadId' => upload_id})
48
+ })
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Storage
3
+ class InternetArchive
4
+ class Real
5
+ # Get a hash of hidden fields for form uploading to S3, in the form {:field_name => :field_value}
6
+ # Form should look like: <form action="http://#{bucket_name}.#{Fog::InternetArchive::API_DOMAIN_NAME}/" method="post" enctype="multipart/form-data">
7
+ # These hidden fields should then appear, followed by a field named 'file' which is either a textarea or file input.
8
+ #
9
+ # @param options Hash:
10
+ # @option options acl [String] access control list, in ['private', 'public-read', 'public-read-write', 'authenticated-read', 'bucket-owner-read', 'bucket-owner-full-control']
11
+ # @option options Cache-Control [String] same as REST header
12
+ # @option options Content-Type [String] same as REST header
13
+ # @option options Content-Disposition [String] same as REST header
14
+ # @option options Content-Encoding [String] same as REST header
15
+ # @option options Expires same as REST header
16
+ # @option options key key for object, set to '${filename}' to use filename provided by user
17
+ # @option options policy security policy for upload
18
+ # @option options success_action_redirect url to redirct to upon success
19
+ # @option options success_action_status status code to return on success, in [200, 201, 204]
20
+ # @option options x-amz-security token devpay security token
21
+ # @option options x-amz-meta... meta data tags
22
+ #
23
+ # @see http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTForms.html
24
+ #
25
+ def post_object_hidden_fields(options = {})
26
+ if options['policy']
27
+ options['policy'] = Base64.encode64(Fog::JSON.encode(options['policy'])).gsub("\n", "")
28
+ options['AWSAccessKeyId'] = @ia_access_key_id
29
+ options['Signature'] = Base64.encode64(@hmac.sign(options['policy'])).gsub("\n", "")
30
+ end
31
+ options
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end