Q: Uploading/downloading content programatically?

Jul 10, 2010 at 9:59 AM

Wondering if its possible to upload/download to SkyDrive using this method?

 

Thanks in advance!

Sincerely,

Adam

Oct 20, 2010 at 1:34 AM

you could programaticly mount the folder then upload and ownload

Dec 15, 2010 at 5:34 AM

Yes good question. I'm interesting too!

Atually if you use mapped drive you can work with it like with other flsers and even i tested it wth sync framework filesync scenarios but after 1-2 syncs i can't enter the drive.

Does anyone know how to solve it? I doesn't use any thirdparty code. Just System.IO and Microsoft.Syncronization.

Error still happened without using sync fx.

 

Dec 15, 2010 at 11:07 PM

Thans for your program. I'm using it for Microsoft Office WebApps. I have set file extension association to my script for Office xls;xlsx;doc;docx. Office's file is uploaded to SkyDrive "My documents" folder in my account and then opened in WebApps Office. After close its saved back to original location.

SkyDrive.cmd

:: Usage    : SkyDrive.cmd "c:\data\file.xls"
:: Usage    : use Types ( http://izt.name/apps/types/ ) to set Explorer ContextMenu "C:\Program Files (x86)\SkyDrive\SkyDrive.cmd" "%1" for doc;docx;xls;xlsx
:: Tested on: Windows 7 EN x64
:: ToDo     : renaming xls<-->xlsx ; doc<-->docx
::main
setlocal 
setlocal ENABLEDELAYEDEXPANSION
:: ---------------- CONFIG-BEGIN ----------------
set SkyDriveLogin=login@domain.com
set SkyDrivePassword=password
set SkyDriveFolder=My Documents
set SkyDriveShare=O:
set SkyDriveDumpUrls=C:\Program Files (x86)\SkyDrive\DumpUrls.exe
:: ---------------- CONFIG-END ----------------
set file=%1
set filename=%~nx1
set filepath=%~dp1
:: replace spaces with %20
set SkyDriveFolderNoSpace=!SkyDriveFolder: =%%20!
:: Get SkyDrive CID
for /f "tokens=*" %%a in ('"%SkyDriveDumpUrls%" %SkyDriveLogin% %SkyDrivePassword%') do set cid=%%a
set cid=%cid:https://dvpdwm.docs.live.net/=%
set cid=!cid:/%SkyDriveFolderNoSpace%=!
:: Check if "net use" exists and using valid CID
if NOT exist %SkyDriveShare%\ (
   goto :mount
) else (
   for /f "tokens=1,2,*" %%a in ('net use %SkyDriveShare% ^| find "Remote name"') do echo %%c | findstr /l /i /c:"%cid%"
   if NOT !errorlevel!==0 goto :unmount
)
goto :openfile
:unmount
net use %SkyDriveShare% /delete /Y
:mount
net use %SkyDriveShare% https://dvpdwm.docs.live.net/%cid%/%SkyDriveFolderNoSpace% /user:%SkyDriveLogin% %SkyDrivePassword%
:openfile
if {"%filename%"}=={""} (
  :: if no arguments, open folder
  call "C:\Program Files (x86)\Internet Explorer\iexplore.exe" https://cid-%cid%.office.live.com/browse.aspx/%SkyDriveFolder%
) else (
  :: copy file to SkyDrive and open in OfficeWebApps
  call del /Q "%SkyDriveShare%\%filename%"?
  call copy %1 "%SkyDriveShare%\%filename%"
  call "C:\Program Files (x86)\Internet Explorer\iexplore.exe" https://cid-%cid%.office.live.com/edit.aspx/%SkyDriveFolder%/%filename%
  :: wait 10sec for correct saving of Office file back to SkyDrive
  ping -n 10 127.0.0.1
  call copy /Y "%SkyDriveShare%\%filename%"? "%filepath%*.*"
  call del /Q "%SkyDriveShare%\%filename%"?
)
goto :EOF
exit
Oct 14, 2011 at 1:16 AM

How did you get the CID for each user?

Oct 14, 2011 at 6:10 PM

who is "each user" ?

user in my script is specified :
set
SkyDriveLogin=login@domain.com
set SkyDrivePassword=password

and CID is taken by tool DumpUrls.exe