Can you explain why the android client analyzes multi-factor data in chat without ascii. while file uploading works fine using a postman here is my app.js code
var multipart = require('connect-multiparty'); var apiRoutes = require('./routes/apiRoutes'); app.set('views', path.join(__dirname, 'views')); app.use(logger('dev')); app.use(bodyParser.json({limit: '50mb'})); app.use(bodyParser.urlencoded([{extended: false},{ uploadDir:path.join(__dirname, 'uploads') }, {parameterLimit:100000}, {limit: '50mb'}])); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'uploads'))); app.use(multipart()); app.use(apiRoutes);
and apiRoutes indicate that my load function contains a simple req param parameter. use postman is working fine
console.log("mediaChat called", req.body, req.files);
answer
mediaChat called { apiKey: '123' } { media: { fieldName: 'media', originalFilename: 'default.png', path: '/tmp/KFnwsKGp-f4woTaBH6aPR-qa.png', headers: { 'content-disposition': 'form-data; name="media"; filename="default.png"', 'content-type': 'image/png' }, size: 716, name: 'default.png', type: 'image/png' } }
here is my client code for Android (note that this working code works with php $ _FILE but does not work with expression)
com.info.acruss.wave; import android.os.AsyncTask; import android.util.Log; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class UploadImage extends AsyncTask<Void, Void, String> { String CallingURL; URL url; OnTaskCompleted myListener; private static final String TAG = "UploadImage"; int timeoutMilli = 60000; String sourceFileUri; String ApiKey,Type; public UploadImage(String sourceFileUri, String URL,String apiKey, String type, OnTaskCompleted listener) { Log.e("Uploading", "API:" + URL); this.sourceFileUri = sourceFileUri; this.CallingURL = URL; this.myListener = listener; this.ApiKey=apiKey; this.Type=type; try { url = new URL(CallingURL); Log.e(TAG, "Url : " + CallingURL); } catch (MalformedURLException e) { e.printStackTrace(); } } @Override protected String doInBackground(Void... params) { String fileName = sourceFileUri; HttpURLConnection conn = null; DataOutputStream dos = null; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int bytesRead, bytesAvailable, bufferSize; byte[] buffer; int maxBufferSize = 10 * 1024 * 1024; File sourceFile = new File(sourceFileUri); if (!sourceFile.isFile()) { Log.e("UploadImage", "Source File Does not exist"; return null; } String serverResponseMessage = ""; try {
using android, this wired answer shows below:
mediaChat called {null: ' \ u0000 \ u0010JFIF \ u0000 \ u0001 \ u0001 \ u0000 \ u0000 \ u0001 \ u0000 \ u0001 \ u0000 \ u0000 \ u0000C \ u0000 \ u0010 \ u000b \ f \ u000e \ f \ n \ u0010 \ u000e \ r \ u000e \ u0012 \ u0011 \ u0010 \ u0013 \ u0018 (\ u001a \ u0018 \ u0016 \ u0016 \ u00181 #% \ u001d (: 3 = Mqypdx \\ egc \ u0000C \ u0001 \ u0011 \ u0012 \ u0012 \ u0018 \ u0015 \ u0018 / \ u001a \ u001a / cB8Bccccccccccccc ....
\ u001f. [ _ \ u0014) M XIjX 7 ` = / 8` รฏDส \ u0018 D # V # q ~ m q10L ' }
I also tried multer and another multiprocessor handler, but noted the work. please help me out of this hell.