Comments (10)
That's a good idea.
I think I also have a strategy for figuring out my Reader.Length which in my limited testing seems to be working and the file transfer seems to be matching when comparing checksums. Next week I will try with more than just simulated data.
Thanks for all your help.
from rb-libcurl.
It sounds like you're using the demo window. What happens if you use the cURLClient class directly?
Dim file As FolderItem = SpecialFolder.Desktop.Child("file.pdf")
Dim upload As BinaryStream = BinaryStream.Open(file)
Dim curl As New cURLClient
curl.Username = "username"
curl.Password = "password"
If curl.Put("smb://192.168.1.10/delete-me/file.pdf", upload) Then
MsgBox("Success")
Else
MsgBox("Error: " + libcURL.FormatError(curl.LastError))
End If
upload.Close()
My suspicion is that the problem lies in the demo window rather than in the project proper.
from rb-libcurl.
Funnily enough, I just sat down to write a minimal example like you posted as I wondered something similar.
With your above code I run into the same problem. I never get either of the Success or Error MsgBox popups. The main thread hangs. The debug messages shows the "Connected to 192.168.1.10 (192.168.1.10) port 445 (#0)" but then nothing.
If I break out into the debugger it is always in the cURLSession.Perform
function. Stepping through it seems like the MultiHandle.PerformOnce
function just keeps looping (but to be honest I don't understand exactly what is happening, your code is way above my head!)
Again, if I change to a WebDav URL, everything works as expected.
from rb-libcurl.
There is a known bug (curl/curl#7896) in curl where SMB uploads from stdin generate an empty file and then hang. It's not quite the same (we're not using stdin), but otherwise it seems to match. One of the comments suggests that specifying the upload size in advance might help:
Call curl.SetOption(libcURL.Opts.INFILESIZE, file.Length) ' use INFILESIZE_LARGE for files >2GB
It might also be enlightening to see the debug output from a successful command line upload. Add -v
to the command line for verbose mode.
from rb-libcurl.
Spending a bit more time trying to understand what is happening... for some reason the code keeps entering EasyHandle.curlRead
even though the UploadStream.Read(sz)
returns 0 bytes because it is at the end of the file.
Not much info in the verbose output.
nick.h@Nicks-MBP Desktop % curl -v -T file.pdf -u user:password smb://192.168.1.10/delete-me/file.pdf
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 192.168.1.10:445...
* Connected to 192.168.1.10 (192.168.1.10) port 445 (#0)
100 25024 0 0 100 25024 0 374k --:--:-- --:--:-- --:--:-- 444k
* Connection #0 to host 192.168.1.10 left intact
I will try adding the file size and see if that helps.
from rb-libcurl.
Genius!
Adding Call curl.SetOption(libcURL.Opts.INFILESIZE, file.Length)
before curl.Put
gives a successful upload!
from rb-libcurl.
Hmmmm, now I just need to work out how I implement that in my code with the custom Readable class that I have written that does not know the size of the data... nuts 🤣
from rb-libcurl.
According to the libcurl documentation:
This option (INFILESIZE) does not limit how much data libcurl will actually send, as that is controlled entirely by what the read callback returns, but telling one value and sending a different amount may lead to errors.
So maybe if you specify a ridiculously large size in advance? It might generate an error, but I wonder if the file will be uploaded anyway.
from rb-libcurl.
Thanks. I had the same thought but when I tried it was back to hanging, stuck in the same cURLSession.Perform
loop.
I am working on my code with some known file lengths to make sure that setting the filesize works in conjunction with the custom Readable class, then I will have a think about the best way to deal with the unknown (maybe just telling the users they have to use WebDAV 😜)
from rb-libcurl.
Calling cURLClient.Abort()
should break the loop and cause an error. This will require some juggling since the code that waits for the EOF has to run concurrently with the code that's performing the transfer. Which means either using asynchronous transfers to run both on the event loop/main thread, or using two separate threads.
curl.Put("smb://192.168.1.10/delete-me/file.pdf", upload) ' async Put()
Do Until upload.EOF
App.DoEvents() // do not do this in real code. Use a Timer to detect the EOF
Loop
curl.Abort()
upload.Close()
from rb-libcurl.
Related Issues (20)
- cURLMulti performs transfers on the main thread regardless of the calling thread HOT 1
- cURLItem leaks socket descriptors
- MultiHandle should not remove finished EasyHandles automatically HOT 1
- cURLManager should use QueryInterval more
- cURLManager should be able to handle multiple simultaneous transfers HOT 1
- ListPtr should allow read access to the underlying slist HOT 1
- Headers are not deleted when have a blank value, even though they should HOT 3
- cURLManager.Constructor(cURLManager) shouldn't need to know whether the EasyHandle is a subclass HOT 1
- EasyHandle.LastError overwritten by debugger HOT 1
- 64-bit not supported HOT 3
- CookieEngine can't be turned off HOT 1
- How to get result from a POST call HOT 4
- Doesn't find libcurl.dll HOT 1
- cannot GET data from one specific URL HOT 2
- DEFAULT_CA_INFO_PEM does not exist HOT 1
- FollowRedirects at POST HOT 2
- PUT returns bad/illegal format or missing URL on ARM 64-bit HOT 21
- ResponseHeaderEngine raises a FunctionNotFoundException on older versions of libcurl if the request didn't generate any headers
- --data-urlencode methods not available? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rb-libcurl.