Onedrive to AWS S3 Buget Data Upload

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

image

Thanks
Shyam

1 Like

Hello @Shyam_Pragash!

It seems that you have trouble getting an answer to your question in the first 24 hours.
Let us give you a few hints and helpful links.

First, make sure you browsed through our Forum FAQ Beginner’s Guide. It will teach you what should be included in your topic.

You can check out some of our resources directly, see below:

  1. Always search first. It is the best way to quickly find your answer. Check out the image icon for that.
    Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution.

  2. Topic that contains most common solutions with example project files can be found here.

  3. Read our official documentation where you can find a lot of information and instructions about each of our products:

  4. Watch the videos on our official YouTube channel for more visual tutorials.

Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.

Thank you for helping us build our UiPath Community!

Cheers from your friendly
Forum_Staff