How to upload file from linux to sharepoint site

This article will focus on how to make connection to upload and download files to sharepoint site through linux shell script.
I tried using curl as below but I did not get output neither the file uploaded.
curl --ntlm --user username:password --upload-file myfile.xls https–://sharepointserver.com/sites/mysite/myfile.xls

thanks.

Hi Ali,

The URL in your command seems malformed. https- (or https–) can not be part of a valid URL, or is that only a copy-paste error?

Also, try to run the command with the verbose argument, and please share the output, that may give some clues on what goes wrong.

hi sadmann,

thank you very much.
we will try to use third party to upload files to Sharepoint site.

thank you

Hi ali, does sharepoint work well for all type as of now?

Hi guys,
Was this problem resolved? If yes then could you quote it

No i have tried this but not working.
curl --ntlm --user mithlesh:mlsh@1723 --upload-file 1test.sh https:/sharepoint.com/sites/Release/1test.sh

Any solution to copy directly from linux server to sharepoint ?

Has anybody actually manage to get this working with SharepointOnline(hereafter abbreviated to SPO)? I created an app on SPO, with appropriate permissions. I then created a script to retrieve the token from SPO, which works fine, but when trying to use the token to upload to SPO, I keep getting a 401 error, thinking I might have a error in my CURL command.

curl -i -H “Authorization: Bearer $(./get_access_token.sh)” -H “Accept: application/json;odata=verbose” --upload-file testfile destination(sorry seems new users cannot post urls)

Hi Laurencew,

Does this curl command works if you don’t run the token retriever on the fly, but insert the token as plain text?

Hi sandmann, the problem is the token changes every time you query it, so by the time I have copied it and inserted into the upload, the token is no longer valid, so need to do it on the fly

Hi Laurencew,

This makes sense, because curl by default does not keeps the session, so from the server side the requests are distinct sessions, thus get distinct tokens. I would suggest digging a bit around curl’s session keeping, cookie handling and such. While that should work on most websites, I’m not sure about Sharepoint.