using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Amazon.DynamoDBv2.DataModel
{
public partial class S3Link
{
///
/// If enable is set to true the object will have its permission set to PublicRead otherwise the permissions will be set to Private.
///
/// If true the object will have its permission set to PublicRead otherwise the permissions will be set to Private.
public void MakeS3ObjectPublic(bool enable)
{
this.s3ClientCache.GetClient(this.RegionAsEndpoint).MakeObjectPublic(this.linker.s3.bucket, this.linker.s3.key, enable);
}
#region Upload/PutObject
///
/// Uploads the specified file and stores it in the specified bucket with the provided key from construction.
///
/// Path of the file to be uploaded.
public void UploadFrom(string sourcePath)
{
this.s3ClientCache.GetClient(this.RegionAsEndpoint).UploadObjectFromFilePath(this.linker.s3.bucket, this.linker.s3.key, sourcePath, null);
}
///
/// Uploads the stream and stores it in the specified bucket with the provided key from construction.
///
/// Stream to upload.
public void UploadStream(Stream stream)
{
this.s3ClientCache.GetClient(this.RegionAsEndpoint).UploadObjectFromStream(this.linker.s3.bucket, this.linker.s3.key, stream, null);
}
#endregion
#region Download/GetObject
///
/// Downloads the file from the S3Link's specified bucket and key then saves it in the given path.
/// Creates directories and the file if they do not already exist.
///
/// Path to save the file.
public void DownloadTo(string downloadPath)
{
this.s3ClientCache.GetClient(this.RegionAsEndpoint).DownloadToFilePath(this.linker.s3.bucket, this.linker.s3.key, downloadPath, null);
}
///
/// Open stream to the data stored in Amazon S3.
///
/// Stream to the data stored in Amazon S3.
public Stream OpenStream()
{
return this.s3ClientCache.GetClient(this.RegionAsEndpoint).GetObjectStream(this.linker.s3.bucket, this.linker.s3.key, null);
}
#endregion
}
}