简体   繁体   English

将输入标识为本地文件夹或 s3 存储桶

[英]identifying the input as local folder or s3 bucket

Source could be local folder or s3 bucket.来源可以是本地文件夹或 s3 存储桶。 How we can make input parameter to identify entered parameter as local folder or s3 bucket?我们如何使输入参数将输入的参数识别为本地文件夹或 s3 存储桶?

s3 bucket is accessed using path style mentioned here: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html You should write pattern check on your input to identify if the input is s3 bucket or bucket object.使用此处提到的路径样式访问 s3 存储桶: https : //docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html您应该对输入编写模式检查以识别输入是 s3 存储桶还是存储桶对象.

Other way, if your input for local path is always going to exists on the system, then you can run path canonicalization commands and get absolute path of the local folder.其他方式,如果您对本地路径的输入始终存在于系统上,那么您可以运行路径规范化命令并获取本地文件夹的绝对路径。 eg on Unix you can run realpath() system api.例如在 Unix 上,您可以运行 realpath() 系统 api。 http://man7.org/linux/man-pages/man3/realpath.3.html http://man7.org/linux/man-pages/man3/realpath.3.html

realpath() api will resolve to actual path only when the input path exists otherwise it returns the error. realpath() api 只有在输入路径存在时才会解析为实际路径,否则返回错误。 You can send your input to realpath command, if it passes, it is your local path on the system.您可以将您的输入发送到 realpath 命令,如果它通过,则它是您在系统上的本地路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM