Uploading a large file in multipart using OkHttp

Get OkHttp 2.1, and use MultipartBuilder.addFormDataPart() which takes the filename as a parameter. /** * Upload Image * * @param memberId * @param sourceImageFile * @return */ public static JSONObject uploadImage(String memberId, String sourceImageFile) { try { File sourceFile = new File(sourceImageFile); Log.d(TAG, “File…::::” + sourceFile + ” : ” + sourceFile.exists()); //Determining the media … Read more

How do you upload a file to an FTP server?

Use the FTPClient Class from the Apache Commons Net library. This is a snippet with an example: FTPClient client = new FTPClient(); FileInputStream fis = null; try { client.connect(“ftp.domain.com”); client.login(“admin”, “secret”); // // Create an InputStream of the file to be uploaded // String filename = “Touch.dat”; fis = new FileInputStream(filename); // // Store file … Read more

Request.Files in ASP.NET CORE

This is working code from a recent project. Data has been moved from Request.Files to Request.Form.Files. In case you need to convert stream to byte array – this is the only implementation that worked for me. Others would return empty array. using System.IO; var filePath = Path.GetTempFileName(); foreach (var formFile in Request.Form.Files) { if (formFile.Length … Read more

Node.js, multer and req.body empty

2017 Update From Readme Note that req.body might not have been fully populated yet. It depends on the order that the client transmits fields and files to the server. I resolved my issue by reversing the order of my form object properties in the front end: var newFormObj = new FormData(); newFormObj.append(‘internalUserID’, internalUserID); newFormObj.append(‘listingImage’, this.binaryImages[image]); … Read more