我正在使用此脚本尝试使用cURL将文件上传到S3存储桶。
#S3 parameters
$S3KEY="AKIAYZL7ANTULMU355OD"
$S3SECRET="AKIAYZL7ANTULMU355OD"
$S3BUCKET="quixel-ml-team-data"
$S3STORAGETYPE="STANDARD" #REDUCED_REDUNDANCY or STANDARD etc.
$AWSREGION="us-west-2"
file_path="C:\Users\DELL\AppData\Local\Temp\input_settings.txt"
aws_path="seam-removal\"
bucket="${S3BUCKET}"
date=$(date -R)
acl="x-amz-acl:private"
content_type="application/x-compressed-tar"
storage_type="x-amz-storage-class:${S3STORAGETYPE}"
string="PUT\n\n$content_type\n$date\n$acl\n$storage_type\n/$bucket$aws_path${file_path##/*/}"
signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)
curl -s --retry 3 --retry-delay 10 -X PUT -T "$file_path" \
-H "Host: $bucket.${AWSREGION}.amazonaws.com" \
-H "Date: $date" \
-H "Content-Type: $content_type" \
-H "$storage_type" \
-H "$acl" \
-H "Authorization: AWS ${S3KEY}:$signature" \
"https://$bucket.${AWSREGION}.amazonaws.com$aws_path${file_path##/*/}"
然而,我还是遇到了这些错误。你知道这些错误吗?对不起,我是这类编程的新手。
file_path=C:\Users\DELL\AppData\Local\Temp\input_settings.txt : The term
'file_path=C:\Users\DELL\AppData\Local\Temp\input_settings.txt' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:11 char:1
+ file_path="C:\Users\DELL\AppData\Local\Temp\input_settings.txt"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (file_path=C:\Us...ut_settings.txt:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
aws_path=seam-removal\ : The term 'aws_path=seam-removal\' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:12 char:1
+ aws_path="seam-removal\"
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (aws_path=seam-removal\:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
bucket=${S3BUCKET} : The term 'bucket=${S3BUCKET}' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:13 char:1
+ bucket="${S3BUCKET}"
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (bucket=${S3BUCKET}:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
date=$(date -R) : The term 'date=$(date -R)' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:14 char:1
+ date=$(date -R)
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (date=$(date -R):String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
acl=x-amz-acl:private : The term 'acl=x-amz-acl:private' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:15 char:1
+ acl="x-amz-acl:private"
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (acl=x-amz-acl:private:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
content_type=application/x-compressed-tar : The term 'content_type=application/x-compressed-tar' is not recognized as
the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:16 char:1
+ content_type="application/x-compressed-tar"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (content_type=ap...-compressed-tar:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
storage_type=x-amz-storage-class:${S3STORAGETYPE} : The term 'storage_type=x-amz-storage-class:${S3STORAGETYPE}' is
not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:17 char:1
+ storage_type="x-amz-storage-class:${S3STORAGETYPE}"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (storage_type=x-...{S3STORAGETYPE}:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
string=PUT\n\n$content_type\n$date\n$acl\n$storage_type\n/$bucket$aws_path${file_path##/*/} : The module 'string=PUT'
could not be loaded. For more information, run 'Import-Module string=PUT'.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:18 char:1
+ string="PUT\n\n$content_type\n$date\n$acl\n$storage_type\n/$bucket$aw ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (string=PUT\n\n$...file_path##/*/}:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoLoadModule
signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64) : The term 'signature=$(echo -en
"${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:19 char:1
+ signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (signature=$(ech...inary | base64):String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Invoke-WebRequest : Parameter cannot be processed because the parameter name 'T' is ambiguous. Possible matches
include: -TimeoutSec -TransferEncoding.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:20 char:43
+ curl -s --retry 3 --retry-delay 10 -X PUT -T "$file_path" \
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
-H : The term '-H' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:21 char:5
+ -H "Host: $bucket.${AWSREGION}.amazonaws.com" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:22 char:5
+ -H "Date: $date" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:23 char:5
+ -H "Content-Type: $content_type" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:24 char:5
+ -H "$storage_type" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:25 char:5
+ -H "$acl" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:26 char:5
+ -H "Authorization: AWS ${S3KEY}:$signature" \
~~
- 类别信息:未找到对象:(-H:字符串)[],未找到命令异常
- 完全限定的错误ID:未找到命令异常
1条答案
按热度按时间esyap4oy1#
您将PowerShell与传统的Unix脚本混合在一起。
此外,由于PowerShell内置了类似的功能,因此无需调用OpenSSL和Curl等外部实用程序。要在不使用AWS SDK的情况下对URL进行签名并执行上传,脚本应如下所示: