-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The .xlsx file uploaded on the server has size of 0 B #1605
Comments
@intest I know it is hard but we need a working example, else there's nothing we can do: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue |
Yes, I know the page How-to-Submit, but I don't think it's necessary to do all that things to reproduce the issue. It's quite simple - upload worked in 0.9.6 and now it fails, I didn't change anything in my environment, beside the Karate version. |
@intest -- Have you tried using "classpath:" instead of "this:"? Or adding the Excel file to the same folder as your feature file and getting rid of both prefaces? Or changing "test.xlsx" to "thisFileDoesNotExist.xlsx" to see what the end result is (does some ghost file with a size of 0 bytes get uploaded in this case, too)? Can you replicate the issue here?: https://encodable.com/uploaddemo This could very well be an issue...but even if it is, there might be a simple work-around for it (without having to downgrade to 0.9.6). I ran into some cookie-related issues with v1.0.0 (fixed now) that were easily resolved by manually referencing a previously-generated Cookie header and plugging it into my subsequent requests, e.g. |
@staffier Thanks for a comment and suggestions. Yes, I have tried everything. I spent two working days trying millions times until I finally decided to check older Karate version :) The original file's name is something like "This Is a File.xlsx", so I changed the name for dozens variants, also changed "this:", "classpath:" etc. Nothing worked. I also tried with .csv file and the result was always the same - the uploaded file was 0B size. It is also very difficult for me to prepare a working example to show the problem, as I use AWS S3 server for uploading the file, so I don't know how can I replace it in the example. I cannot provide my credentials :/ |
@ptrthomas is there any chance to fix it, please...? I tried literally everything and didn't find a working solution :( I don't know what details can I provide, but I'm using exactly the same configuration, server etc. in both cases (0.9.6 and latest versions), so there are no other differences. Additionally I have a question (if this is an issue and new ticket is needed then I create one):
Was that function readAsString introduced in newest Karate version than 0.9.6? PS. Alternativelly I do: |
@intest I added a test and it works fine, refer this file: https://github.com/intuit/karate/blob/a41bf767f8af423791591bb978d894a2261676a0/karate-core/src/test/java/com/intuit/karate/core/mock/upload.feature I think the mistake you have been making all along is this |
@ptrthomas Thank you for testing that, but unfortunatelly it still doesn't work for me.
and I can't remember the other dozens of examples... But it doesn't matter, because the result is always the same. File is uploaded successfully with Karate 0.9.6, and with Karate 1.0.0 and above the file has 0 B size: The only hint I can make: I use |
@intest I have an example that works, so now it is completely up to you. we'll release 1.1.0.RC3 in a day or two, but you can try the developer guide to see if the latest version in another thing I would try is force a the mock for the example I linked to above is super-simple. here it is below, so you can experiment with that and run your own server - and you should be able to create a fresh, stand-alone example of the whole dang flow in a few minutes (refer https://github.com/intuit/karate/wiki/ZIP-Release#api-mocks) Feature:
Scenario: pathMatches('/upload')
* def filePart = requestParts['myFile'][0]
* def response = filePart and the test is: Feature:
Scenario:
* url 'http://localhost:8080'
* path 'upload'
* multipart file myFile = { read: 'test.xlsx', filename: 'my-file.xlsx', contentType: 'text/csv' }
* method post
* status 200
* match response == { charset: 'UTF-8', filename: 'my-file.xlsx', transferEncoding: 'binary', name: 'myFile', contentType: 'text/csv', value: '#ignore' } all the very best. |
Hi @ptrthomas . I appreciate your help, but after another dozens tries, it still doesn't work for me.
It doesn't occur with others content types, like |
indeed very strange ! |
@ptrthomas Just fyi: with 1.1.0.RC3 'text/csv' works, I mean there is no NullPointerException anymore, but the main problem remains - 0 B size. I'm giving up ;D |
And just as a prove, that with 0.9.6 the upload works :) Nothing else changed in my code or/and environment. What's been changed in Karate between 0.9.6 and 1.0.0? Some external libraries, anything I could check..? |
@intest here is the diff between 0.9.6 and 1.0 I'm sure your detective skills will find the culprit in no time: v0.9.6...v1.0.0 |
Thanks, but.. why so sarcastic..? I'm trying to find a solution. And to help, cause maybe not only me have this problem (or maybe only me..?) |
@intest sorry, since you were so confident that you proved a point above and that nothing changed etc :) just ignore me please |
Heh.. Yes, I did no change in any character of my code. Just switched between Karate versions :) I can be confident in that point. |
@intest I believe you ;) okay, just want to make it clear I've tried every thing possible to help you. multiple people asked you to submit at least a cURL snippet but it has been ignored. if we can't get a way to replicate, it ain't an issue. it may sound harsh to you - but that's how it is. can it be a change in karate behavior from 0.9.6 to 1.0 oh ABSO-fing-LUTELY. |
OK, let's cool the atmosphere. I really appreciate every kind of help, but honestly - generating a cURL snippet from another tool doesn't make sense in this case, since it worked in 0.9.6, so it's not an issue with the request I'm sending. Sorry for bothering, but this issue is so frustrating and enigmatic.. :/ |
lol, you raised the issue on stack-overflow saying that "it works in P0stman" and now this. how convenient. now I strongly suspect whether it works in P0stman or not. prove it :) and of course you completely missed the point that the cURL helps other developers figure out what's unique about the request. I'm locking this thread as "too heated". you can open a new one if needed, but it does sound like tools like P0stman are simpler and possibly a better fit for you. peace. |
The issue described initially here: https://stackoverflow.com/questions/67606009/how-to-upload-xlsx-file-successfully
The upload of .xlsx files not working properly in versions 1.0.0 and above. The file uploaded has a size of 0 B on the server.
This is a code I'm using in my scenario. It works correctly in 0.9.6.
I hope that above description is enough to investigate and fix the problem.
The text was updated successfully, but these errors were encountered: