Exemplo n.º 1
0
        /// <summary>
        /// Moves the file to a a new location in S3.
        /// </summary>
        /// <param name="path">The target directory to copy to.</param>
        /// <exception cref="T:System.IO.IOException">If the file already exists in S3.</exception>
        /// <exception cref="T:System.ArgumentException"></exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>S3FileInfo for the target location.</returns>
        public S3FileInfo MoveTo(S3DirectoryInfo path)
        {
            S3FileInfo ret = CopyTo(path, false);

            Delete();
            return(ret);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Replaces the destination file with the content of this file and then deletes the orignial file.  If a backupDir is specifed then the content of destination file is 
 /// backup to it.
 /// </summary>
 /// <param name="destDir">Where the contents of this file will be copy to.</param>
 /// <param name="backupDir">If specified the destFile is backup to it.</param>
 /// <exception cref="T:System.ArgumentException"></exception>
 /// <exception cref="T:System.IO.IOException"></exception>
 /// <exception cref="T:System.Net.WebException"></exception>
 /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
 /// <returns>S3FileInfo of the destination file.</returns>
 public S3FileInfo Replace(S3DirectoryInfo destDir, S3DirectoryInfo backupDir)
 {
     S3FileInfo ret = Replace(
         new S3FileInfo(destDir.S3Client, destDir.BucketName, string.Format(CultureInfo.InvariantCulture, "{0}{1}", destDir.ObjectKey, Name)),
         backupDir == null ? null : new S3FileInfo(backupDir.S3Client, backupDir.BucketName, string.Format(CultureInfo.InvariantCulture, "{0}{1}", backupDir.ObjectKey, Name)));
     return ret;
 }
        /// <summary>
        /// Creates a sub directory inside the instance of S3DirectoryInfo.
        /// </summary>
        /// <param name="directory"></param>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns></returns>
        public S3DirectoryInfo CreateSubdirectory(string directory)
        {
            S3DirectoryInfo ret = null;

            ret = GetDirectory(directory);
            ret.Create();
            return(ret);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Replaces the destination file with the content of this file and then deletes the orignial file.  If a backupDir is specifed then the content of destination file is
        /// backup to it.
        /// </summary>
        /// <param name="destDir">Where the contents of this file will be copy to.</param>
        /// <param name="backupDir">If specified the destFile is backup to it.</param>
        /// <exception cref="T:System.ArgumentException"></exception>
        /// <exception cref="T:System.IO.IOException"></exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>S3FileInfo of the destination file.</returns>
        public S3FileInfo Replace(S3DirectoryInfo destDir, S3DirectoryInfo backupDir)
        {
            S3FileInfo ret = Replace(
                new S3FileInfo(destDir.S3Client, destDir.BucketName, String.Format("{0}{1}", destDir.ObjectKey, Name)),
                backupDir == null ? null : new S3FileInfo(backupDir.S3Client, backupDir.BucketName, String.Format("{0}{1}", backupDir.ObjectKey, Name)));

            return(ret);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Copies this file to the target directory.
        /// If the file already exists in S3 and overwrite is set to false than an ArgumentException is thrown.
        /// </summary>
        /// <param name="dir">Target directory where to copy the file to.</param>
        /// <param name="overwrite">Determines whether the file can be overwritten.</param>
        /// <exception cref="T:System.ArgumentException">If the directory does not exist.</exception>
        /// <exception cref="T:System.IO.IOException">If the file already exists in S3 and overwrite is set to false.</exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>S3FileInfo of the newly copied file.</returns>
        public S3FileInfo CopyTo(S3DirectoryInfo dir, bool overwrite)
        {
            if (!dir.Exists)
            {
                throw new ArgumentException("directory does not exist", "dir");
            }

            S3FileInfo ret = CopyTo(new S3FileInfo(dir.S3Client, dir.BucketName, string.Format(CultureInfo.InvariantCulture, "{0}{1}", dir.ObjectKey, Name)),overwrite);
            return ret;
        }
        /// <summary>
        /// Returns the S3DirectoryInfo for the specified sub directory.
        /// </summary>
        /// <param name="directory">Directory to get the S3DirectroyInfo for.</param>
        /// <returns>The S3DirectoryInfo for the specified sub directory.</returns>
        public S3DirectoryInfo GetDirectory(string directory)
        {
            S3DirectoryInfo ret = null;

            if (String.IsNullOrEmpty(bucket))
            {
                ret = new S3DirectoryInfo(s3Client, directory, "");
            }
            else
            {
                ret = new S3DirectoryInfo(s3Client, bucket, string.Format(CultureInfo.InvariantCulture, "{0}{1}", key, directory));
            }
            return(ret);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Copies this file to the target directory.
 /// If the file already exists in S3 than an ArgumentException is thrown.
 /// </summary>
 /// <param name="dir">Target directory where to copy the file to.</param>
 /// <exception cref="T:System.ArgumentException">If the directory does not exist.</exception>
 /// <exception cref="T:System.IO.IOException">If the file already exists in S3.</exception>
 /// <exception cref="T:System.Net.WebException"></exception>
 /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
 /// <returns>S3FileInfo of the newly copied file.</returns>
 public S3FileInfo CopyTo(S3DirectoryInfo dir)
 {
     return(CopyTo(dir, false));
 }