Hi Team,
How to download the Onedrive Data folders to AWS S3 Buget data folders.
is there any sample code for this share… i am trying to in vb.net code getting an error
I will Share the code and error message. How to fix it or any option to completed.
' Set up your OneDrive and S3 credentials
Dim oneDriveAccessToken As String = "your_onedrive_access_token"
Dim s3AccessKey As String = "your_s3_access_key"
Dim s3SecretKey As String = "your_s3_secret_key"
Dim s3BucketName As String = "your_s3_bucket_name"
' Authenticate with OneDrive and S3
Dim oneDriveClient As New Microsoft.Graph.OneDriveClient(oneDriveAccessToken)
Dim s3Client As New Amazon.S3.AmazonS3Client(s3AccessKey, s3SecretKey, Amazon.RegionEndpoint.USWest2) ' Adjust region as necessary
' List folders in OneDrive
Dim oneDriveFolders As List(Of String) = oneDriveClient.ListFolders()
' Loop through each folder
For Each folder As String In oneDriveFolders
' List files in folder
Dim files As List(Of String) = oneDriveClient.ListFiles(folder)
' Loop through each file
For Each file As String In files
' Check if file is in mp4 format
If file.EndsWith(".mp4") Then
' Check if file already exists in S3 bucket
Dim key As String = System.IO.Path.GetFileName(file)
Dim request As New Amazon.S3.Model.GetObjectMetadataRequest With {
.BucketName = s3BucketName,
.Key = key
}
Try
s3Client.GetObjectMetadata(request)
Console.WriteLine("File " & file & " already exists in S3 bucket.")
Catch ex As Amazon.S3.AmazonS3Exception
If ex.StatusCode = System.Net.HttpStatusCode.NotFound Then
' Upload file to S3 bucket
Dim transferUtility As New Amazon.S3.Transfer.TransferUtility(s3Client)
Dim filePath As String = "path_to_your_local_file_directory\" & file ' Adjust path as necessary
Dim uploadRequest As New Amazon.S3.Transfer.TransferUtilityUploadRequest With {
.BucketName = s3BucketName,
.FilePath = filePath,
.Key = key
}
transferUtility.Upload(uploadRequest)
Else
Throw ' Rethrow other exceptions
End If
End Try
End If
Next
Next

Thanks
Shyam