pellegrinimarcos / plsql-utils

Automatically exported from code.google.com/p/plsql-utils
0 stars 0 forks source link

AMAZON_AWS_S3_PKG - set_object_acl (enhancement suggestion) #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This procedure allows the caller to modify the permissions for an object in a 
bucket.

AMAZON_AWS_S3_PKG spec

  -- modify the access control list for an object
  procedure set_object_acl (p_bucket_name in varchar2,
                            p_key in varchar2,
                            p_acl in varchar2);

AMAZON_AWS_S3_PKG body

procedure set_object_acl (p_bucket_name in varchar2,
                          p_key in varchar2,
                          p_acl in varchar2) is

  l_key                          varchar2(4000) := utl_url.escape (p_key);

  l_clob                         clob;
  l_xml                          xmltype;

  l_date_str                     varchar2(255);
  l_auth_str                     varchar2(255);

  l_header_names                 t_str_array := t_str_array();
  l_header_values                t_str_array := t_str_array();

begin

  /*

  Purpose:   modify the access control list (owner and grantees) for an object

  Remarks:

  Who     Date        Description
  ------  ----------  -------------------------------------
  JKEMP   22.09.2012  Created

  */

  l_date_str := amazon_aws_auth_pkg.get_date_string;
  l_auth_str := amazon_aws_auth_pkg.get_auth_string ('PUT' || chr(10) || chr(10) || chr(10) || l_date_str || chr(10) || 'x-amz-acl:' || p_acl || chr(10) || '/' || p_bucket_name || '/' || l_key || '?acl');

  l_header_names.extend;
  l_header_names(1) := 'Host';
  l_header_values.extend;
  l_header_values(1) := get_host(p_bucket_name);

  l_header_names.extend;
  l_header_names(2) := 'Date';
  l_header_values.extend;
  l_header_values(2) := l_date_str;

  l_header_names.extend;
  l_header_names(3) := 'Authorization';
  l_header_values.extend;
  l_header_values(3) := l_auth_str;

  l_header_names.extend;
  l_header_names(4) := 'x-amz-acl';
  l_header_values.extend;
  l_header_values(4) := p_acl;

  l_clob := make_request (get_url(p_bucket_name, l_key) || '?acl', 'PUT', l_header_names, l_header_values);

  check_for_errors (l_clob);

end set_object_acl;

Original issue reported on code.google.com by jeffrey....@jk64.com on 22 Sep 2012 at 12:43

GoogleCodeExporter commented 8 years ago

Original comment by thehunge...@gmail.com on 25 Sep 2012 at 6:36

GoogleCodeExporter commented 8 years ago
Feature implemented in latest version of library.

Original comment by thehunge...@gmail.com on 17 Feb 2013 at 9:21