Adding some examples of the S3 bucket object parameters as well as checking for an empty string in the new S3 bucket object params
This commit is contained in:
parent
2b7a13b609
commit
0a5387db90
|
@ -76,30 +76,40 @@ func resourceAwsS3BucketObjectPut(d *schema.ResourceData, meta interface{}) erro
|
|||
|
||||
bucket := d.Get("bucket").(string)
|
||||
key := d.Get("key").(string)
|
||||
source := d.Get("source").(string)
|
||||
encoding := d.Get("content_encoding").(string)
|
||||
contentType := d.Get("content_type").(string)
|
||||
cacheControl := d.Get("cache_control").(string)
|
||||
contentLanguage := d.Get("content_language").(string)
|
||||
contentDisposition := d.Get("content_disposition").(string)
|
||||
|
||||
source := d.Get("source").(string)
|
||||
file, err := os.Open(source)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error opening S3 bucket object source (%s): %s", source, err)
|
||||
}
|
||||
putInput := &s3.PutObjectInput{
|
||||
Bucket: aws.String(bucket),
|
||||
Key: aws.String(key),
|
||||
Body: file,
|
||||
}
|
||||
|
||||
resp, err := s3conn.PutObject(
|
||||
&s3.PutObjectInput{
|
||||
Bucket: aws.String(bucket),
|
||||
Key: aws.String(key),
|
||||
Body: file,
|
||||
CacheControl: aws.String(cacheControl),
|
||||
ContentDisposition: aws.String(contentDisposition),
|
||||
ContentEncoding: aws.String(encoding),
|
||||
ContentLanguage: aws.String(contentLanguage),
|
||||
ContentType: aws.String(contentType),
|
||||
})
|
||||
if v, ok := d.GetOk("cache_control"); ok {
|
||||
putInput.CacheControl = aws.String(v.(string))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("content_type"); ok {
|
||||
putInput.ContentType = aws.String(v.(string))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("content_encoding"); ok {
|
||||
putInput.ContentEncoding = aws.String(v.(string))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("content_language"); ok {
|
||||
putInput.ContentLanguage = aws.String(v.(string))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("content_disposition"); ok {
|
||||
putInput.ContentDisposition = aws.String(v.(string))
|
||||
}
|
||||
|
||||
resp, err := s3conn.PutObject(putInput)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error putting object in S3 bucket (%s): %s", bucket, err)
|
||||
|
|
|
@ -29,11 +29,11 @@ The following arguments are supported:
|
|||
* `bucket` - (Required) The name of the bucket to put the file in.
|
||||
* `key` - (Required) The name of the object once it is in the bucket.
|
||||
* `source` - (Required) The path to the source file being uploaded to the bucket.
|
||||
* `cache_control` - (Optional) Specifies caching behavior along the request/reply chain.
|
||||
* `content_disposition` - (Optional) Specifies presentational information for the object.
|
||||
* `content_encoding` - (Optional) Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
|
||||
* `content_language` - (Optional) The language the content is in.
|
||||
* `content_type` - (Optional) A standard MIME type describing the format of the object data.
|
||||
* `cache_control` - (Optional) Specifies caching behavior along the request/reply chain Read [w3c cache_control](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9) for futher details.
|
||||
* `content_disposition` - (Optional) Specifies presentational information for the object. Read [wc3 content_disposition](http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1) for further information.
|
||||
* `content_encoding` - (Optional) Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read [w3c content encoding](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11) for further information.
|
||||
* `content_language` - (Optional) The language the content is in e.g. en-US or en-GB.
|
||||
* `content_type` - (Optional) A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input.
|
||||
|
||||
## Attributes Reference
|
||||
|
||||
|
|
Loading…
Reference in New Issue