I want to compress a file to ".tgz" extension using apache camel 3.11.1.
As the gzip format is not supported, I tried GZipDeflater data format but it is not working (the file remains unchanged).
I found a solution, maybe it can help someone else.
The solution was to use gzipDeflater DataFormat, and explicitly provide the extension in the file endpoint when producing the result:
from("file:...../in?noop=true")
.marshal().gzipDeflater()
.to("....../out1?fileName=${file:name.noext}.tgz");
Related
I am writing a batch based on
https://github.com/dataArtisans/flink-training-exercises/blob/master/src/main/java/com/dataartisans/flinktraining/exercises/dataset_java/mail_count/MailCount.java
In the following code, input has to be .csv, otherwise I get error. I tried a .zip file with a csv in it. In the MailCount.java, I see that the readCsvFile accepts .gz file as input and works fine. Could you please help?
env.readCsvFile(input)
.ignoreFirstLine()
.includeFields(fields)
.types(String.class,String.class);
Thanks
Aruna
Flink supports reading compressed files out of the box, if the files have a proper extension. However, not all types of compression are supported. You can find the list of supported compression types in [1].
For example, .gz is supported, that's why the example works, but .zip isn't, so you get an error.
Best regards,
Konstantin
[1] https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/batch/index.html#read-compressed-files
The thing is, I am writing the config file for Logstash with file input plugin. The purpose is to setup a accommodated .conf file so that everybody can use it. Thus I will use environment variable $HOME to get the home directory of user, because the log path is related to that. However, when I am trying to do that, for example:
"path" => "${HOME}/file.log"
I found Logstash only accepts absolute path, like "/home/usr/file.log".
Anything like ../logs or ./logs all did not work.
So I am wondering, is there any other method I can do this?
Thanks in advance.
Not within the scope of logstash configuration.
Paths must be absolute and cannot be relative.
Source: file input documentation
With enough determination the answer is never, truly, no. You could use some tool, a script or program, maybe a templating language, to edit your logstash config file.
How do I decompress a compressed file in a rhomobile application?
I saw that the zlib extension is unavailable in rhodes, because it needs a ruby port. Ruby uses the "zlib.c" or "zlib.h" source files and not a portable zlib.
When running the rhodes application, in a line with the source:
require 'zlib'
it raises the error:
no such file to load -- zlib
Anyone has any idea?
Thanks in advance?
See the documentation on adding libaries to your Rhodes app: http://wiki.rhomobile.com/index.php/RhodesExtensions#Adding_Libraries_to_Your_Rhodes_Application
I don't know if zlib will work or not (actually would be curious what you find out). If you have more questions I suggest the Rhomobile google group.
Read MP3 Tags with Silverlight got me started with reading id3 tags, but i realize that taglib# online deals with local file paths ?
Is there a way of reading this info from a remote file ?
I recently answered the same question for Ruby (see below) - I'm pretty sure you can do something similar.
The idea is:
use HTTP 1.1 protocol or higher, and a Range HTTP-request.
download the beginning section (100 bytes) of the ID3v2-tag
from the first few bytes downloaded, you can determine the correct length of the complete ID3v2 tag, e.g. N
download the first N bytes of the file (e.g. the complete ID3v2-tag)
parse the ID3v2 tag for your purposes
See:
Read ID3 Tags of Remote MP3 File in Ruby/Rails?
Tim Heuer has a good blog post on doing this. http://timheuer.com/blog/archive/2010/01/30/reading-mp3-id3-tags-with-silverlight-taglib.aspx
Like yourself, he also ran into the problem of TabLib# only using local paths.
One thing that TagLib# didn’t have was a stream input implementation. Most of the libraries, in fact, assumed a local file path. Luckily the library was written using a generic ‘File’ interface, so I just had to create my own StreamFileAbstraction. I chose to do this within my project rather than the base library. It was easy since the LocalFileAbstraction actually perfomed an Open on the file as it’s first task and set some public variables. My abstraction basically just hands the stream already and ready to go.
There is an example on the novell site that uses file abstraction.
http:// developer.novell.com/wiki/index.php/TagLib_Sharp:_Examples
A webapp I've been developing allows users to upload and download a type of file which is meant to be treated as an opaque blob. My app serves it up with a file extension not commonly used for any other purpose, as well as specifying that its MIME Content-Type is application/octet-stream.
Internally, the file is a simple Zip archive containing a single compressed file. What I've found is that IE6 apparently inspects the content of the file, determines that it's a Zip archive, and "helpfully" saves it with an additional ".zip" extension. Unbelievable!
As I mentioned, this file is meant to be opaque, and we don't want users to be poking around inside the file--not because it's dangerous or contains sensitive information or anything, we just don't want to confuse them. I suggested prepending the Zip content with a magic number to prevent IE6 from recognizing it, but my manager says he'd prefer it if the file content could remain unchanged, so that knowledgeable people can rename the file and examine its contents as a zip archive, if necessary.
Is there any way to tell IE6 to keep its mitts off of the file? Or any alternative approach at all? (Alas, just not supporting IE6 at all is not an option.)
Incidentally, IE7 respects the file's name, but still identifies it as a Zip archive in the download dialog. That's better than IE6, but still less than ideal.
Short answer: Add correct MIME types to you web server so IE6 doesn't guess the file type.
Long Answer:
My work had a similar problem with Microsoft PowerPoint files.
.ppt vs .pps - Which are identical files with different extensions. We wanted the user to view a show (.pps) but IE6 kept changing it to .ppt. It changed the extention because the users machine had PowerPoint installed and understood that the file "looked" like a . ppt. Don't understand why not .pps.
The problem, besides IE6, was that our web server (IIS) was not aware of either MIME types for .pps or .ppt. So we had to add the correct MIME types so the server would not deliver them as "application/octet-stream". I understand that by using "application/octet-stream" IE6 will try to guess the MIME type.
So we added:
.pps = "application/vnd.ms-powerpoint"
.ppt = "application/vnd.ms-powerpoint"
Now it works fine with IE6.
I hope this helps solve your problem.
use this header flag: Content-Disposition: attachment; filename="yourfilename.extension"
This is a known problem, and the only solution is to edit the client computer's registry, which I'm sure doesn't help you a lot.