简体   繁体   English

如何将大文件分割成较小的文件(对FTP更友好),然后再合并回去?

[英]How do I split a big file into smaller ones (more FTP friendly), and merge them back later?

My server doesnt allow upload/download of big files. 我的服务器不允许上传/下载大文件。 On the other hand, I built a bootstrapper that needs to upload/download big files. 另一方面,我构建了一个引导程序,需要上传/下载大文件。 How can I split a big file into smaller subfiles.. and do the merging later on? 如何将大文件拆分为较小的子文件,然后进行合并? An already done c# library would be great... but I'm happy hear suggestions about how to program this myself... or even use a utility. 一个已经完成的c#库将是很棒的……但是我很高兴听到有关如何自己编程的建议……甚至使用实用程序。

** Windows platform ** ** Windows平台**

On Unix, you can use the split command to break apart the file, and then use cat to concatenate them together. 在Unix上,可以使用split命令将文件分解,然后使用cat将它们连接在一起。

split -b 1024M bigfile.tar.gz bigfile

This will create oodles of files like bigfileaa bigfileab, etc. So then ftp all the little beasties to the destination and do the cat: 这将创建大文件,例如bigf​​ileaa bigfileab等。因此,将所有小野兽ftp到目的地,然后执行以下操作:

cat bigfile* > bigfile.tar.gz

On Windows, you might have an option in your Zip application to break apart an archive and remerge it on the other end. 在Windows上,您的Zip应用程序中可能有一个选项可以拆分存档,然后在另一端重新合并。 Actually, a googling of the search terms: zip split turns up several such options. 实际上,对搜索词进行谷歌搜索: zip split出现了几个这样的选项。

On windows you can easyly split it with WinRar. 在Windows上,您可以使用WinRar轻松拆分它。

Or you do it "with your own hand": 或者,您可以“用自己的双手”进行操作:

1) 1 1) 1

2) 2 2) 2

Every zip program I've ever used has this ability. 我曾经使用过的每个zip程序都具有此功能。

7zip is my current favorite on windows. 7zip是我目前在Windows上的最爱。 It has a nice command line version, too. 它也有一个不错的命令行版本。

You can make a split and join program with a handful of lines each. 您可以创建一个splitjoin程序,每个程序只有几行。 Just read some fixed amount (512KB, 4MB, whatever) from a file and write it out to a new file. 只需从文件中读取一些固定量(512KB,4MB,无论什么),然后将其写到新文件中即可。 Repeat this (and change the filename you write to) until you reach the end of the file. 重复此过程(并更改写入的文件名),直到到达文件末尾。

Another program needs to read from these files and write their contents (one after another) to a target file. 另一个程序需要从这些文件读取并将它们的内容(一个接一个)写入目标文件。

Pretty easy, really, and if you want to get some programming experience it would be a good exercise. 确实,这很容易,并且如果您想获得一些编程经验,那将是一个不错的练习。

或者,您可以编写一个小型应用程序来满足您的需要...先读取字节然后再写入....因此,它可以轻松地将大文件拆分为小文件

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

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