aws codecommit put-file not working properly

0

I'm trying to push individual files to a CodeCommit repository following the instructions at https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-create-file.html with AWS CLI. My command reads: aws codecommit put-file --repository-name MY_REPOSITORY --branch-name main --file-content my_file_name.py --file-path GUI/my_file_name.py --parent-commit-id a7ddbb7a99dd37c9e2c5fe378eba1187xxxxxxxx --name "Name" --email "my-email" --commit-message "Adding file from EC2 instance." The problem is that it creates the file but the content of the file is NOT the content of my_file_name.py (a bunch of python lines) but the only line of the new file reads literally my_file_name.py. Thanks.

질문됨 4달 전189회 조회
1개 답변
1
수락된 답변

To correctly upload the content of my_file_name.py, you should use the file:// prefix with the --file-content parameter, which tells the AWS CLI to read the content from the specified file. Your command should look like this:

aws codecommit put-file \
    --repository-name MY_REPOSITORY \
    --branch-name main \
    --file-content file://path/to/my_file_name.py \
    --file-path GUI/my_file_name.py \
    --parent-commit-id a7ddbb7a99dd37c9e2c5fe378eba1187xxxxxxxx \
    --name "Name" \
    --email "my-email" \
    --commit-message "Adding file from EC2 instance."

profile picture
전문가
답변함 4달 전
profile picture
전문가
검토됨 4달 전
  • This is bit odd. It works for transferring a file from the home directory but when, I try pushing from the /opt directory, it's generating the error "Error parsing parameter '--file-content': Unable to load paramfile file:///opt..."

  • You may need to use sudo to elevate access to /opt Or try file://opt/filename.py

  • Sorry but with the storm, I forgot to follow up on this matter. I had tried both options on Friday (even switching to superuser with $ sudo su) but was getting other errors. I'm accepting the answer because this seems to be the best we can do at this point, but this issue should probably be elevated either to the CLI or CodeCommit Teams.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠