multipartform-data

How to handle retrofit socket timeout for uploading files in android kotlin?

强颜欢笑 提交于 2020-07-23 08:36:11
问题 var client = OkHttpClient() val builder = OkHttpClient.Builder() val gson = GsonBuilder() .setLenient() .create() builder.addInterceptor(AddCookiesInterceptor(mcontext)) builder.addInterceptor(ReceivedCookiesInterceptor(mcontext)) builder.callTimeout(100,TimeUnit.SECONDS) client = builder.build() retrofit = Retrofit.Builder() .baseUrl(BASE_URL) .client(client) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) // .addConverterFactory

How to handle retrofit socket timeout for uploading files in android kotlin?

送分小仙女□ 提交于 2020-07-23 08:35:14
问题 var client = OkHttpClient() val builder = OkHttpClient.Builder() val gson = GsonBuilder() .setLenient() .create() builder.addInterceptor(AddCookiesInterceptor(mcontext)) builder.addInterceptor(ReceivedCookiesInterceptor(mcontext)) builder.callTimeout(100,TimeUnit.SECONDS) client = builder.build() retrofit = Retrofit.Builder() .baseUrl(BASE_URL) .client(client) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) // .addConverterFactory

com.facebook.react.bridge.readablenativemap cannot be cast to java.lang.string

▼魔方 西西 提交于 2020-07-18 08:49:04
问题 My code: const file = { uri: this.state.imageSource, name: this.state.imageName, type: 'image/jpg', }; const data = new FormData(); data.append('file', file); fetch(config.server + '/upload', { method: 'POST', body: data, }) .then((res) => res.json()) .then((responseData) => { alert(JSON.stringify(responseData)); }) .catch((err) => { alert(err); }); Without FormData code doesnt display error. What I should do to fix? Debugging on android. 回答1: The error was because I was passing in the url as

FormData sends boolean as string to server

有些话、适合烂在心里 提交于 2020-07-14 06:17:51
问题 I have the following input which is a toggle returns true , false <input id="{{event.id}}" ng-model="event.is_active" type="checkbox" value="true" class="block__input" ng-class="{'input__toggle--active' : event.is_active}"> and when I send it like this var formData = new FormData(); console.log(scope.event.is_active); formData.append('is_active', scope.event.is_active); In the server I receive false and true as strings 'true', 'false' How to solve this problem ? 回答1: FormData will always be

Why does PDF is not able to upload in PHP API for Android Pie, Q and R using Retrofit 2 in Android/Java? [Added Bounty]

此生再无相见时 提交于 2020-07-11 07:15:06
问题 The bounty expires in 6 days . Answers to this question are eligible for a +50 reputation bounty. Priyanka Singh is looking for an up-to-date answer to this question: I need the solution that should work on all version from API 21 to 30 Update: I started Bounty for this question, because accepted solution is working till Oreo version, but my project supports from API level 21 to 30 . Please check end of the question, to see latest updates. I tried to upload a PDF file [ Not Image ] in PHP API

Why does PDF is not able to upload in PHP API for Android Pie, Q and R using Retrofit 2 in Android/Java? [Added Bounty]

£可爱£侵袭症+ 提交于 2020-07-11 07:12:29
问题 The bounty expires in 6 days . Answers to this question are eligible for a +50 reputation bounty. Priyanka Singh is looking for an up-to-date answer to this question: I need the solution that should work on all version from API 21 to 30 Update: I started Bounty for this question, because accepted solution is working till Oreo version, but my project supports from API level 21 to 30 . Please check end of the question, to see latest updates. I tried to upload a PDF file [ Not Image ] in PHP API

upload image from multipart-from-data using Alamofire '~> 5.0.0-beta.3'

有些话、适合烂在心里 提交于 2020-06-27 17:12:14
问题 func uploadImage(image: UIImage, imageUrl: String, imageExtension: String , responseData: @escaping (_ response: UploaderModel)-> ()) { var status : UploaderModel? let token = UserDefaults.standard.string(forKey: PrefKeys.loginToken) ?? "" let authorization = ["Authorization" : "Bearer \(token)"] let imageURl = "http://68.183.152.132/api/v1/stuff/uploader" //Parameter HERE let parameters = [ "garbageCollector": 0, "stuff_uuid": "2b4b750a-f4a6-4d61-84ce-7c42b5c030ee", "delete_file" : "" ] as

Node.js file upload server without third party module

人盡茶涼 提交于 2020-06-27 16:35:09
问题 I want to parse the upload file and saved without any 3rd module but still not success. Do I miss any part? Or it need to convert to buffer first? var http = require('http'); const fs = require ('fs'); http.createServer(function (req, res) { if (req.url == '/fileupload') { var body = ''; req.on('data', (data) => { body += data; }); req.on('end', () => { body = body.replace(/-.+-/g, '').replace(/WebKit.+|Contentdata.+|Content-Type.+/g, ''); fs.writeFile('test.png', body, (err) => { if (err)

spring mvc @RequestPart validation via annotation

冷暖自知 提交于 2020-06-26 19:44:01
问题 How can I validate that the body request part is not empty? @PostMapping("/messages") @ResponseStatus(HttpStatus.CREATED) fun createMessage(@Valid @RequestPart message: MessageCreate, @Valid @RequestPart @NotEmpty body: MultipartFile, @RequestParam attachments: List<MultipartFile>) { return service.create(message, body, attachments) } I tried to create a custom validator annotation that checks body.isEmpty() result but it has no effect. What is missing ? Is it possible do to it this way ? 回答1

.tmp files not being deleted in Multipart Spring MVC File Upload

一笑奈何 提交于 2020-06-25 21:38:52
问题 I've implemented a Spring MVC REST service that accepts a multipart message with both a file upload and a JSON body as the constitutive parts. Here are the main classes involved: My Controller: @RestController public class MyController { @Autowired private MyService myService; @RequestMapping(value = "/publish", method = RequestMethod.POST, consumes = "multipart/form-data", produces = "application/json") public PublishContentResponse publishContent(@RequestPart("json") PublishContentRequest