如何将文件从s3服务下载到本地文件夹 [英] How to download files from s3 service to local folder

查看:399
本文介绍了如何将文件从s3服务下载到本地文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将文件从简单存储服务下载到本地文件夹 并计算本地文件夹中的文件数,并检查简单存储服务,然后发送带有文件数的邮件.

I have requirement to download files from simple storage service to local folder and count the no.of files in local folder and check against simple storage service then send mail with the number of files.

我试图从简单的存储服务中下载文件,但是却出现类似get-s3object commandnotfoundexception的错误.我该如何解决这个问题?

I tried to download files from simple storage service but I am getting error like get-s3object commandnotfoundexception. How do I resolve this issue?

推荐答案

如果已安装AWS PowerShell模块,则尚未将其正确加载到当前会话中.我们将其识别为问题,因为您指定的错误意味着找不到给定的cmdlet.

If you have installed the AWS PowerShell Module, you haven't correctly loaded it into your current session. We're identifying this as the issue because the error you specified means that the given cmdlet can't be found.

首先通过以下任一选项验证模块是否已安装:

Verify first that the module is installed, by any of the options below:

将模块加载到现有会话中:(PowerShell v3和v4):

从文档中:

在PowerShell 4.0和更高版本中,Import-Module还会在Program Files文件夹中搜索已安装的模块,因此不必提供模块的完整路径.您可以运行以下命令来导入AWSPowerShell模块.在PowerShell 3.0和更高版本中,在模块中运行cmdlet还会自动将模块导入会话中.

In PowerShell 4.0 and later releases, Import-Module also searches the Program Files folder for installed modules, so it is not necessary to provide the full path to the module. You can run the following command to import the AWSPowerShell module. In PowerShell 3.0 and later, running a cmdlet in the module also automatically imports a module into your session.

要验证安装是否正确,请将以下命令添加到脚本的开头:

To verify correct installation, add the following command to the beginning of your script:

PS C:\> Import-Module AWSPowerShell

将模块加载到现有会话中:(PowerShell v2):

要验证安装是否正确,请将以下命令添加到脚本的开头:

To verify correct installation, add the following command to the beginning of your script:

PS C:\> Import-Module "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1"

使用Windows PowerShell for AWS Desktop Shortcut打开新会话:

一个快捷方式被添加到您的桌面,该快捷方式在将正确的模块加载到会话中的情况下启动PowerShell.如果安装成功,则应该显示此快捷方式,并且应该正确加载AWS PowerShell模块,而无需您付出额外的努力.

A shortcut is added to your desktop that starts PowerShell with the correct module loaded into the session. If your installation was successful, this shortcut should be present and should also correctly load the AWS PowerShell module without additional effort from you.

从文档中:

安装程序会创建一个名为Amazon Web Services的开始菜单组, 其中包含一个称为Windows PowerShell for AWS的快捷方式.为了 PowerShell 2.0,此快捷方式自动导入AWSPowerShell 模块,然后运行Initialize-AWSDefaults cmdlet.对于PowerShell 3.0中,每当您运行AWS cmdlet时,都会自动加载AWSPowerShell模块.因此,对于PowerShell 3.0,由 安装程序仅运行Initialize-AWSDefaults cmdlet.欲了解更多 有关Initialize-AWSDefaults的信息,请参阅使用AWS凭证.

The installer creates a Start Menu group called, Amazon Web Services, which contains a shortcut called Windows PowerShell for AWS. For PowerShell 2.0, this shortcut automatically imports the AWSPowerShell module and then runs the Initialize-AWSDefaults cmdlet. For PowerShell 3.0, the AWSPowerShell module is loaded automatically whenever you run an AWS cmdlet. So, for PowerShell 3.0, the shortcut created by the installer only runs the Initialize-AWSDefaults cmdlet. For more information about Initialize-AWSDefaults, see Using AWS Credentials.

进一步阅读:

  • AWS PowerShell Documentation - Download and Install the AWS Tools for Windows PowerShell
  • AWS PowerShell Documentation - Setting up the AWS Tools for Windows PowerShell

这篇关于如何将文件从s3服务下载到本地文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆