w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
C# Creating and Sending Zip files with gmail
Quote from the MSDN: Compressed GZipStream objects written to a file with an extension of .gz can be decompressed using many common compression tools GZip files are not really "zip" files. They usually use "gz" as file extension. You might try that, maybe Gmail is very strict about "matching" extensions and compression formats. If you are using .NET 4.5 you can alternatively use the ZipArchive class. That one actually handles "zip" files.

Categories : C#

Android - Sending 2 files to a server
I could not get this to work, so instead I used Base64 encoding and BasicNameValuePair and managed to upload it that way. Regardless, if someone has an idea about what was wrong with the code in the question, and how to fix it I would like to know. Works fine now, code follows: private void filesToSend() { File f1=new File(id.getText().toString()); File f2=new File(ccd.getText().toString()); if (f1.exists()&&f2.exists()) { Bitmap bip1=BitmapFactory.decodeFile(f1.getAbsolutePath()); Bitmap bip2=BitmapFactory.decodeFile(f2.getAbsolutePath()); ByteArrayOutputStream stream1=new ByteArrayOutputStream(); ByteArrayOutputStream stream2=new ByteArrayOutputStream(); bip1.compress(Bitmap.CompressFormat.JPEG, 90, stream1); //compress to whi

Categories : Android

Sending Image Files back to the Browser
That's good for development/testing (but don't forget to return null after closing response). But never do this on production system. You need a frontend server in front of your Tomcat, like Nginx or Apache HTTPD server. I recommend Nginx. For Nginx you could use following configuration to serve this files: location /item/getImage/ { alias /path/to/directory/with/images; } location / { //proxy to your Tomcat instance proxy_pass http://127.0.0.1:8080; }

Categories : Java

Sending non-text files via UDP doesn't work
From client.c: int nbrecv = 0; while(flag == 1){ memset(buffer, '', BUFFER_SIZE); if((nbrecv = recvfrom(s, buffer, BUFFER_SIZE, 0, &remote, &len_remote)) == -1){ fprintf(stderr, "fail while receiving data! "); exit(-1); } count += nbrecv; printf("n = %d ", nbrecv); fwrite(buffer, 1, nbrecv, output); if(nbrecv<1024){ flag = 0; } } recvfrom() will return the number of received bytes, use it. Be aware that UDP doesn't have any guarantees (the packets are'nt re-ordered, or whatever). If you use UDP, you may want to create a basic protocol which will contain some informations (number of the packet, number of bytes in the packet, etc.).

Categories : C

Sending JSON files to iPhone for iOS app testing
You can put the file in the application bundle (ensure it's there in XCode, under the Copy Bundle Resources section on the Build Phases tab for the project), then access the file directly with no path, with simply default.json. However, any files in the application bundle are read only. Alternatively, if you wish to be able to update the file, your app should typically copy the file from the application bundle to the documents folder on first launch, and then access the copy in the documents folder from then on. (Hint: If the file doesn't exist in the documents folder, copy it from the application bundle.) When distributing an app, only the files included in the application bundle are delivered. When run on a device from XCode, only the application bundle is copied to the device, and all

Categories : Iphone

Sending headers with server cached files
In your code below include the header(); calls before the include($cachefile) statement. if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile))) { // Serve from the cache if it is younger than $cachetime include($cachefile); //echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." -->"; echo "/* Cached ".date('jS F Y H:i', filemtime($cachefile))." */"; }

Categories : PHP

Android sharing Files, by sending them via email or other apps
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(exportPath)); also you can make zip file of all file and attach zip file for send multiple file in android

Categories : Java

Hadoop: Sending Files or File paths to a map reduce job
Both are valid. But latter would incur extra overhead and performance will go down because you are talking about concatenating all the files into one and feeding it to just 1 mapper. And by doing that you would go against one of the most basic principles of Hadoop, parallelism. Parallelism is what makes Hadoop so efficient. FYI, if you really need to do that you have to set isSplittable to false in your InputFormat class, otherwise the framework will split the file(based on your InputFormat). And as far as input path is considered, you just need to give the path of the input directory. Each file inside this directory will be processed without human intervention. HTH In response to your edit : I think you have misunderstood this a bit. You don't have to worry about localization. Had

Categories : File

Node Express sending image files as API response
There is an api in Express. res.sendFile app.get('/report/:chart_id/:user_id', function (req, res) { // res.sendFile(filepath); }); http://expressjs.com/api.html#res.sendfile

Categories : Image

PHP force download, not sending full binary files
I know this is an older thread but I have the solution for everyone here. You have a script somewhere in your application that's compressing spaces or other characters. ob_start("sanitize_output"); That was the problem in one scenario I noticed. If you turn off the buffer reduction script (called "sanitize_output" above) then your .pdf will show up normally. That extra 2kb's you noticed that were trimmed was probably from spacing or cutting out unneeded characters.

Categories : PHP

Error upon sending and executing multiple test files
Here is your code re-factored. The sleeps/gotos were really bothering me. I couldn't really test it, but I think it should work the same. Let me know if it doesn't work or you have any questions. This assumes your listbox has content like this in it: testname.cmd test2.cmd test3.exe lasttest.bat Here is my attempt: public void executeCommandFiles() { foreach (string test in listboxTestsToRun.Items) { //gets the directory name from given filename (filename without extension) //assumes that only the last '.' is for the extension. test.1.cmd => test.1 string testName = test.Substring(0, test.LastIndexOf('.')); //set up a FileInfo object so we can make sure the test exists gracefully. FileInfo testFile = new FileInfo(@"Y:Tests" + testN

Categories : C#

How to handle a Client/Server application for sending message and/or files
Your question made me curious, how a modern java approach would look like. I also had some problems as I started experimenting with sockets, so here a little example that should help you out. The server handles each client in its own 'thread', you could say that's the basic client/server architecture. But I used the new Callable<V> instead of threads. I did not extend Socket nor ServerSocket. I nerver saw that before. I think it's better in that case to favor composition over inheritance. It gives you more control, since you can delegate what and how you prefer. For more information I recommend you to take a look at the oracle tutorials. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.Server

Categories : Java

Issue with sending prn files to printer : Printing is extremely slow
Change the final P1 to P20 - the number following P is copies-to-print Since that didn't work, try changing the S2 to S3 and so on to S6. The max speed setting depends on printer model. Even so, S2 should give you 2" per second... In the absence of a response to whether the "S" command change affected matters, I'll offer the source, EPL Programming Guide - which should be official and credible enough - page 144, or "EPL2 Programmer's Manual" (Zebra manual No 98009-001 Revision D) Page 2-56

Categories : Windows

ApplicationError: 10 on sending files to Google Cloud Storage using the Java remote API from App Engine
This was a bug. It was fixed in this change: https://code.google.com/p/appengine-gcs-client/source/detail?r=104 Sync to the latest version in the SVN and it should go away.

Categories : Java

AFNetworking sending NSDictionary as single array values instead of sending them as complete objects
I think the issue comes about because you're using a default HTTP POST with arguments to send your value. You can confirm this by printing out the content-type of the post on the server side; it should be something along the lines of x-www-form-urlencoded. If that's the case, that data format can't really express arrays and dictionaries well. So you get the odd format you're seeing on the server side. What you probably want to do is send your data as JSON, not as plain form parameters. I believe the thing you want to do is set the parameterEncoding property of your AFHTTPClient to AFJSONParameterEncoding. This will send your request as JSON, which is capable of representing arrays and dictionaries correctly on the wire.

Categories : IOS

Sending data to google wallet it is sending response merchant error
The demo sample you are pointing to seems to work fine. You can also try some additional sample code in various languages (Java, Python, PHP): https://developers.google.com/commerce/wallet/digital/docs/samples MERCHANT_ERROR implies that something is wrong with the purchase request such as a badly formatted JWT. If you are trying to re-use the sample code in your app make sure to generate a new JWT using your Seller ID and Seller Secret.

Categories : Android

Android Email sending failed with error Fail to send: IOException while sending message
Try public final static String APP_PATH_SD_CARD = "/Images_Book/filetobeattached.ext"; Instead of public final static String APP_PATH_SD_CARD = "/Images_Book/";

Categories : Android

Error while sending attachments via Openerp 7 'Social Network' app but works fine while sending normal message
It's a bug. The reason being that context is not passed correctly when you click on the "Compose New Message" button or other send message buttons. The bug has been reported. They should be working on it by now.

Categories : Python

Sending email through MS Access VBA / Outlook, choosing sending profile
You need to log to the specified profile. After creating an instance of the Outlook application Set oApp = CreateObject("Outlook.application") add something like the following: set oNS = oApp.GetNamespace.Logon oNS.Logon("MyProfileName") Note if Outlook is already running, Logon will do nothing. You will need to use Extended MAPI (C++ or Delphi or a MAPI wrapper like Redemption (RDOSession.Logon) to log to a specified profile. Why not work with a single profile and create multiple accpunts? You can then set the MailItem.SendUsaingAccount property to specify a particular account.

Categories : Vba

POI not sending xls file as attachment , sending as string
The problem is not related to POI, but with JavaMail (plus the way different email clients handles the specs and malformed emails). Try this: Multipart multipart = new MimeMultipart(); MimeBodyPart html = new MimeBodyPart(); // Use actual html not "strstr" html.setContent("<html><body><h1>Hi</h1></body></html>", "text/html"); multipart.addBodyPart(html); // ... // Joop Eggen suggestion to avoid spaces in the file name String fileName = "Service_Change_Alert_" + new SimpleDateFormat("yyyy-MM-dd_HH:mm").format(date) + ".xlsx"; ByteArrayOutputStream baos = new ByteArrayOutputStream(); updateDataBook.write(baos); byte[] poiBytes = baos.toByteArray(); // Can be followed by the DataSource / DataHandler stuff if you really need it MimeBodyPart at

Categories : Apache

How to move large number of files files on disk to HDFS sequence files
Seems like a few lines of code with Camel. i.e. from("file:/..").to("hdfs:..") plus some init and project setup. Not sure how much easier (less lines of code) you can do it using any method. If the HDFS options in Camel is enough for configuration and flexibility, then I guess this approach is the best. Should take you just a matter of hours (or even minutes) to have some test cases up and running.

Categories : Apache

why my jsp 's compiled files i.e java files n class files are not visible in work folder
You can find where the class resides (inside a jar or whatever), via: <!-- This classes URL: <%= getClass().getProtectionDomain().getCodeSource() .getLocation().toExternalForm(); %> --> The getLocation delivers an URL.

Categories : Jsp

When when sending an email of zip file size 19mb its not sending the email?
Try sending a simple text file to vet your solution even works. If that comes through, then your ISP may be filtering. Some ISP's have 5mb limits. Also make sure you only have pictures in those zips. If you have any exes etcs those can be blocked. Check your spam folder. Really though, just make sure a text attachment goes through.

Categories : C#

What is platform independent way of converting csv files to tsv files if the csv files can be quoted with comma inside the quoted strings?
Text::CSV_XS (XS is the C version of the module, and is faster than native Perl Text::CSV) is the usual tool of choice. It handles quoted (and comma containing) fields easily can be used for both reading and writing Can switch between delimiters so you can have a writer object using TAB. Example (sans error handling): my $csv_in = Text::CSV_XS->new ({ binary => 1 }); my $csv_out = Text::CSV_XS->new ({ binary => 1, sep_char => " ", eol => " " }); open my $fh_in, "<", "file_in.csv" or die "file_in.csv: $!"; open my $fh_out, ">", "file_out.csv" or die "file_out.csv: $!"; while (my $row = $csv_in->getline($fh_in)) { $csv_out->print ($fh_out, $row) } close $fh_in; close $fh_out;

Categories : Perl

App's locale files affect Engine's locale files. It force to have the same files in the hosting app. How fix it?
So I figured out where was the problem. I my engine's engine.rb file I had such a code for initialization. The problem was with receiver of config. Since I provide an app instance to the block, the receiver of config is app. And that caused the problem: initializer("my_engine.locales") do |app| tracking_logger = Logger.new(app.root.join('log', "my_engine_log.log"), 10, 30*1024*1024) config.i18n.load_path += Dir[root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = :ru config.i18n.fallbacks = [:en] tracking_logger.debug "MyEngine::Engine specific locale settings are set. Def locale == :ru " end So I changed the receiver to MyEngine and now everything works just fine: initializer("my_engine.locales") do |app| tracking_logger = Logger.new(app.root.join(

Categories : Ruby On Rails

Problems reading simple numeric values from files in Windows batch files
The issue here is that the entire IF expression is evaluated before the SET /P statement within it can be executed. InstalledVersion is not set yet, and so this invalid expression is evaluated: IF GEQ 2 ( Nothing inside of the IF expression executes because it cannot be completely evaluated. A solution is to enable delayed expansion and replace %InstalledVersion% with !InstalledVersion!, as described in this post. You can also restructure the code so the GEQ comparison happens after the IF expression.

Categories : Windows

Serving static files( including HTML files). Nginx vs Node.js. Which one is more scalable?
Both Node.js and Nginx are asynchronous (non-blocking) servers. Nginx is definitely more well suited for serving your static files. However, depending on your use case, the difference may not be worth the added administration overhead. You would really have to be running a significant amount of traffic before you would notice the difference.

Categories : HTML

How to add security constraints in .clsss files to strict user decompiles class files
I want to add security in my classes so that no one can de-compile my class files or open jar files. You can't. It is mathematically impossible. If someone can get hold of the JAR file / ".class" files, they can extract and decompile the classes. (There are ways to make it a bit harder ... but there is nothing you can do to stop a skilled and motivated attacker ... apart from not delivering code to him, in any form.) I also want to add constraints in my web.xml file so that no one can try to access from another servlet. Also impossible: If you are talking about another servlet in the same web container, then anything you can put into the web.xml file can be edited out by the person who controls web container. If you are talking about a servlet in another web container, th

Categories : Java

Search through directories for specific Excel files and compare data from these files with inputvalues
In answer to the first question "How come I only get one result when I am printing excelfiles()" this is because your return statement is within the nested loop, so the function will stop on the first iteration. I would try building up a list instead and then return this list, you could also combine this with the issue of checking the name e.g. : import os, fnmatch #globals start_dir = os.getenv('md') def excelfiles(pattern): file_list = [] for root, dirs, files in os.walk(start_dir): for filename in files: if fnmatch.fnmatch(filename.lower(), pattern): if filename.endswith(".xls") or filename.endswith(".xlsx") or filename.endswith(".xlsm"): file_list.append(os.path.join(root, filename)) return file_list file_list = ex

Categories : Python

Reinserting XML Comments into a tree of C# source files from the auto generated [assembly].xml files
Since code files are generated using a tool (ILSpy), code style and formatting (whitespaces and indentations) will be same for almost every code file. What I would do is check if decompiling of that 5000+ class library is against the law, write a simple parser to parse code files and find class/method/property definitions check if what I've found matches with what is in xml If everything is ok, then I would copy found xml tags to their new position on code files since now that I know positions of definitions in a file. PS: just a reminder, to ease string replacing/inserting, always do inserting from bottom of the file to top of the file. this way, whenever you insert a line, indexes of other lines to be inserted will remain same.

Categories : C#

.gitignored some files only recently; trying to merge into a previous branch, ignored files show up as conflicts
I would rather, before merging devel to A, making sure all devel ignored files are ignored as well in A. The trick for that is to remove from the index of A everything, update the .gitignore content, and add everything back! git checkout A # update the .gitignore file from devel in A git checkout devel -- .gitignore # remove/add everything git rm --cached -r . git add . git commit -m "new commit with devel gitignore files out" # then git merge devel

Categories : GIT

How to search for few files out of hundred files in UNIX and if not find replace with 0 byte file
Assuming by shell u mean bash: Skeleton to start with: luk32:~/projects/tests$ cat ./process_files.sh #!/bin/bash DEST=./copies for num in "$@"; do file="AllResponses_"$num"_6_20_2013.txt" if [ -f $file ]; then cp $file $DEST else touch $DEST/$file fi done; It takes numbers as arguments, then tries to find a file with given pattern in current working directory. If found copy to destination folder, else touch the file. You will probably have to tinker a little bit to get friendlier than hard-coded date handling. Example: luk32:~/projects/tests$ ls -l total 40116 -rw-r--r-- 1 luk32 luk32 4 cze 21 11:33 AllResponses_1_6_20_2013.txt -rw-r--r-- 1 luk32 luk32 5 cze 21 11:33 AllResponses_3_6_20_2013.txt -rw-r--r-- 1 luk32 luk32 0 cze 21 11:32 AllResponses_4_6_20

Categories : Unix

how to select multiple music files from device,and to save those selected files in some whare
It does not seem like there is a way to select multiple files below API 19. See Select multiple files with Intent.ACTION_GET_CONTENT

Categories : Android

Select multiple files (different files from different directory) with 1 input type file element.
Using more than one <input type="file" /> element for your form is the best you can do. It's not possible to select multiple files from different directories in a single upload dialog.

Categories : HTML

Using command prompt batch files to move and automatically rename duplicate files
I have a pair of utility files that do this, so I can call from either command line, or another batch file. This manages several versions of the file in the same folder, and I would call it before moving your new file in. Usage is: archivefile 5 "c: empsongs" .txt [move] Where 5 is the number of versions to keep. The base file name in this example is "c: empsongs.txt" and it creates (in c: emp) 5 files: songs_1.txt songs_2.txt songs_3.txt songs_4.txt songs_5.txt If you specify move it will move the original songs.txt otherwise it copies it. Note, if you're using it from another batch file (which you'll probably want to), you need to use call or it won't return to your original batch file (both batch files will exit instead, which isn't what you want): call archivefile 5 "c: empsong

Categories : Windows

Bash script that move files from one directory with lots of files to a month folder
something like this? DEBUG=echo cd ${directory_with_files} for file in * ; do dest=$(stat -c %y "$file" | head -c 7) mkdir -p $dest ${DEBUG} mv -v "$file" $dest/$(echo "$file" | sed -e 's/.* (.*)/1/') done DISCLAIMER: test this in a safe copy of your files. I won't be responsible for any lost of data ;-)

Categories : Bash

Find Missing files and sub directories with it's files list while copy and paste?
Can i make one simple exe tool for this. Of course. How to i find that missing files can any one give some guide to do. You need two lists. You'll need to read and fill one, and then read and compare to determine what's missing. The code might look something like this: var targetFiles = new List<string>(); foreach (var f in Directory.GetFiles(targetDir)) { targetFiles.Add(Path.GetFileName(f)); } var missingFiles = new List<string>(); foreach (var f in Directory.GetFiles(sourceDir)) { if (targetFiles.Contains(Path.GetFileName(f))) { continue; } missingFiles.Add(Path.GetFileName(f)); } Now all of the missing files in the target are in the missingFiles list. You can then loop through that list to copy those missing files to the target.

Categories : C#

How to perform better document version control on Excel files and SQL schema files
Since you've tagged your question with git I assume you are asking about git usage for this. Well, SQL dumps are normal text files so it makes perfect sense to track them with git. Just create a repository and store them in it. When you get a new version of a file, simply overwrite it and commit, git will figure out everything for you, and you'll be able to see modification dates, checkout specific versions of this file and compare different versions. The same is true for .xlsx if you decompress them. .xlsx files are zipped up directories of XML files (See How to properly assemble a valid xlsx file from its internal sub-components?). Git will view them as binary unless decompressed. It is possible to unzip the .xlsx and track the changes to the individual XML files inside of the archive

Categories : GIT

Reading txt files and parsing them fast using c++ and boost memory mapped files
Streams are slow. Part is because the constraints that apply to them are onerous, part is because implementations have a tendency of being poorly optimized. Try using Boost.Spirit parsers. While the syntax takes a bit of getting used to and compilation can sometimes be very slow, the runtime performance of Spirit is very high.

Categories : C++

Searching files by matching filename pattern and concatenating contents of the files
for the second NP_len_*.fa pattern the regex can be like .+NP_len_d{1,3}.fa and for the first one where you do not want the N us this .+?[^N]P_len_d{1,3}.fa this one will match all patterns just except N before P. I have considered that folder names might grow in future about you xaa part. you can alternatively match for string of length 3 also.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.