Closed jda2004 closed 4 years ago
Hello, I think you are missing the -FileContent parameter
What do i put in -FileContent, the content of the file? I have a create table DDL in this file. Sould I just copy and paste that content within a single qoute?
I think the simplest way to do this is
-FileContent ([System.IO.File]::ReadAllBytes('path to my file'))
-FilePath
is the relative path to the file in the repository, not the path to a local file.
I am not familiar with these CodeCommit APIs but, if I read the docs correctly, this API will create one new commit for each file you add. In case you want to add multiple files in the same commit, New-CCCommit
should do that.
And............... it worked!!!.... thank you @matteo-prosperi You solved my 4 hours of digging in one shot!!!
Hi @matteo-prosperi : I like to add little more information in my script. So this is the original syntax pattern from aws
Write-CCFile
-RepositoryName
Hi,
I can tell you that -Force
is simply the PowerShell common parameter which will bypass the confirmation prompt of this cmdlet. -Force
doesn't have any CodeCommit-specific use.
When it comes to the other parameters, have a look at the reference docs here. -Name
appears to be "the name of the person adding or updating the file". -FileMode
is one of the values of the FileModeTypeEnum (so you can do -FileMode NORMAL
).
One more :) @matteo-prosperi I am now thinking to put this syntax in an automation tool (WhereScape Red) template that will write the generated load script directly into the codecommit. In this case, I need to enable the FileContent to read a variable string. How to do that? For example: -FileContent ([System.IO.File]::ReadAllBytes('$Loadsql'))
I am not sure I understand whether you have the file name in a variable or the content of the file in a variable. The former would be
-FileContent ([System.IO.File]::ReadAllBytes($FilePath))
the latter
-FileContent ([System.Text.Encoding]::UTF8.GetBytes($SomeText))
Sorry for the confusion on the question, but you answered it with 'the latter' one. And it's working. Thanks for developing this one.
Write-CCFile -RepositoryName test-repo -BranchName master -FilePath /test/tst.tst -ParentCommitId abc123test -ProfileName test-profile
Write-CCFile : The file is empty. Empty files cannot be added to a repository.
I am continuously getting this error message even though the file is not empty. The goal is to write a file in codecommit using this syntax.