IO 错误:寻找本地标头:使用 Archive::Zip、PERL 从远程服务器读取时

发布于 2024-09-28 22:19:31 字数 650 浏览 0 评论 0原文

想要从远程 zip 文件中的 .csv 文件读取内容,而无需下载和下载将 zip 文件解压到本地计算机。

我需要这个,因为文件 zip 文件太大,需要时就下载它 需要更长的时间。

我正在 perl 中尝试这个。

我的代码是: 我的 $ftp = Net::FTP::AutoReconnect->new("ftp.somename.com"); $ftp->login("用户","密码"); $ftp->cwd("路径");

my $fh = Net::FTP::RetrHandle->new($ftp,"filename.zip");
my $zip = Archive::Zip->new($fh);
my @member_names = $zip->memberNames();
my $member1 =  $zip->memberNamed("Basic/BoardDescriptions.csv");

my $string = $member1->contents();
print Dumper $string;

我在调用内容方法时遇到 io::seeking to local header 错误, 直到那个声明我猜代码工作正常。

预先感谢任何尝试过的人。 谢谢。

Want to read the contents from a .csv file which is in a remote zip file without downloading & extracting the zip file to local machine.

I need this because the file zip file size is too large and downloading it whenever needed
takes longer time.

I am trying this in perl.

My code is :
my $ftp = Net::FTP::AutoReconnect->new("ftp.somename.com");
$ftp->login("user","password");
$ftp->cwd("path");

my $fh = Net::FTP::RetrHandle->new($ftp,"filename.zip");
my $zip = Archive::Zip->new($fh);
my @member_names = $zip->memberNames();
my $member1 =  $zip->memberNamed("Basic/BoardDescriptions.csv");

my $string = $member1->contents();
print Dumper $string;

I get io::seeking to local header error while calling contents method,
till that statement i guess the code is working fine.

Thanks in advance to any one who gives a try to it.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拿命拼未来 2024-10-05 22:19:32

我的猜测是这不是 Archive::ZIP 的错..
你能打印@member_names吗?

虽然 Net: :FTP::RetrHandle 确实承诺了这一点:

这最初是为与 Archive::Zip 一起使用而设计的;它足够可靠,可以从远程 ZIP 存档中提取目录和单个文件,而无需下载整个内容。

尝试对另一台服务器上的另一个文件执行相同的操作。

My guess is that this is not Archive::ZIP 's fault ..
can you print @member_names ?

It's not obvious how your'e suppose to extract an individual file, although Net::FTP::RetrHandle does promise it:

This was originally designed for use with Archive::Zip; it's reliable enough that the table of contents and individual files can be extracted from a remote ZIP archive without downloading the whole thing.

Try doing the same with another file from another server..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文