2017-06-14 55 views
2

以下鏈接:https://b2drop.eudat.eu/s/DfQlm5J42nEGnH7保存文件和文件夾(可公開訪問)。請注意,不需要用戶名和密碼。如何使用curl將文件上傳到共享b2drop.eudat(owncloud)存儲庫?

我可以通過下載的zip文件:

wget https://b2drop.eudat.eu/s/DfQlm5J42nEGnH7/download 

這將生成一個下載文件。我可以通過以下方式將其解壓縮:unzip download

在網站的GUI上,當我點擊加號和upload時,它會打開一個部分,我可以選擇要下載哪些文件。我想通過控制檯完成所有這些操作。

enter image description here enter image description here

[Q]從它的GUI我也可以上傳文件。是否可以使用curlwget使用控制檯上傳文件?

以下命令沒有幫助。

curl --upload-file run.sh https://b2drop.eudat.eu/s/DfQlm5J42nEGnH7/ 

我也嘗試從以下鏈接:https://github.com/owncloud/pyocclient,但它也沒有幫助。

oc = owncloud.Client('https://b2drop.eudat.eu/') 
oc.login('[email protected]', password); 
oc.put_file("https:/b2drop.eudat.eu/s/DfQlm5J42nEGnH7", "path/to/upload/run.sh") 
oc.put_file("/s/DfQlm5J42nEGnH7", "path/to/upload/run.sh") 
oc.put_file("/DfQlm5J42nEGnH7", "path/to/upload/run.sh") 

謝謝你寶貴的時間和幫助。

回答

1

從網絡日誌的分析,這是一個PUT請求https://b2drop.eudat.eu/public.php/webdav/<filename>text/plain內容類型與沒有密碼和用戶名DfQlm5J42nEGnH7一個基本的認證。

下面將上傳本地文件run.sh

curl -X PUT -H 'Content-Type: text/plain' \ 
    -H 'Authorization: Basic RGZRbG01SjQybkVHbkg3Og==' \ 
    --data-binary '@run.sh' \ 
    https://b2drop.eudat.eu/public.php/webdav/run.sh 

注意基本身份驗證base64編碼字符串給DfQlm5J42nEGnH7:解碼(用戶名:密碼)

原始網絡日誌:

enter image description here

+0

謝謝。有效!如果我有一個要上傳的文件夾(可能包含一些子文件夾),而不是隻有'run.sh'或'.tar'文件。有沒有簡單的方法來上傳他們呢? @Bertrand Martel – Alper

+0

你是怎麼找到'RGZRbG01SjQybkVHbkg3Og =='的?例如,對於這個新的鏈接:'https:// b2drop.eudat.eu/s/30lETRKHDL8Lpr0'?我嘗試在這個網站(http://www.utilities-online.info/base64/)上編碼'DfQlm5J42nEGnH7',但它提供了不同的輸出,即'RGZRbG01SjQybkVHbkg3'。我想我們必須把每個編碼字符串的'Og =='結尾。 – Alper

+1

這種情況下的基本身份驗證使用'username:password'方案。在你的情況下'301ETRKHDL8Lpr0'是用戶名,所以在base64中編碼'301ETRKHDL8Lpr0:'(介意':'),密碼是空白的 –

相關問題