OCISDK/OCISDK/ObjectStorage/IO/ObjectStorageFileInfo.cs
/// <summary>
/// Copies the file from the local file system to ObjectStorage.
/// If the file already exists in ObjectStorage and overwrite is set to false than an ArgumentException is thrown.
/// </summary>
/// <param name="srcFileName">Location of the file on the local file system to copy.</param>
/// <param name="overwrite">Determines whether the file can be overwritten.</param>
/// <exception cref="T:System.IO.IOException">If the file already exists in ObjectStorage and overwrite is set to false.</exception>
/// <exception cref="T:System.Net.WebException"></exception>
/// <returns>S3FileInfo where the file is copied to.</returns>
Copies the file from the local file system to ObjectStorage.
If the file already exists in ObjectStorage and overwrite is set to false than an ArgumentException is thrown.
Copies the file from the local file system to ObjectStorage . If the file already exists in ObjectStorage and overwrite is set to false than an ArgumentException is thrown .
public ObjectStorageFileInfo CopyFromLocal(string srcFileName, bool overwrite)
        {
            if (!overwrite)
            {
                if (Exists)
                {
                    throw new IOException("File already exists");
                }
            }
            var putObjectRequest = new PutObjectRequest
            {
                NamespaceName = namespaceName,
                BucketName = bucket,
                ObjectName = ObjectStorageHelper.EncodeKey(key)
            };
            using (var stream = File.Open(srcFileName, FileMode.Open))
            {
                putObjectRequest.UploadPartBody = stream;
                var updateRes = client.PutObject(putObjectRequest);
            }
            return this;
        }
public ObjectStorageFileInfo CopyFromLocal ( string srcFileName , bool overwrite ) { if ( ! overwrite ) { if ( Exists ) { throw new IOException ( " " ) ; } } var putObjectRequest = new PutObjectRequest { NamespaceName = namespaceName , BucketName = bucket , ObjectName = ObjectStorageHelper . EncodeKey ( key ) } ; using ( var stream = File . Open ( srcFileName , FileMode . Open ) ) { putObjectRequest . UploadPartBody = stream ; var updateRes = client . PutObject ( putObjectRequest ) ; } return this ; }
Copies the file from the local file system to ObjectStorage.
Copies the file from the local file system to ObjectStorage .
S3FileInfo where the file is copied to.
S3FileInfo where the file is copied to .
If the file already exists in ObjectStorage and overwrite is set to false.
If the file already exists in ObjectStorage and overwrite is set to false .
None
srcFileName
string
Location of the file on the local file system to copy.
Location of the file on the local file system to copy .
overwrite
bool
Determines whether the file can be overwritten.
Determines whether the file can be overwritten .