diff --git a/src/LivingLibrary/LlOneDriveFile.class.st b/src/LivingLibrary/LlOneDriveFile.class.st index 354d51f..0a9c852 100644 --- a/src/LivingLibrary/LlOneDriveFile.class.st +++ b/src/LivingLibrary/LlOneDriveFile.class.st @@ -3,7 +3,8 @@ Class { #superclass : #LlWebResource, #instVars : [ 'owner', - 'file' + 'file', + 'typeCodes' ], #category : #'LivingLibrary-Core' } @@ -11,14 +12,17 @@ Class { { #category : #'instance creation' } LlOneDriveFile class >> fromString: aString [ - | aUrl filePath | + | aUrl filePath owner typeCodes | (aString beginsWith: self urlBase printString) ifFalse: [ self error: 'invalid one drive URL' ]. aUrl := aString asUrl. + typeCodes := RelativePath withAll: (aUrl pathSegments first: 3). + owner := aUrl pathSegments fourth. filePath := RelativePath withAll: (aUrl pathSegments allButFirst: 4). ^ self new - owner: aUrl pathSegments fourth; + owner: owner; + typeCodes: typeCodes; file: filePath; yourself ] @@ -32,13 +36,13 @@ LlOneDriveFile class >> peCanHandleFromString: aString [ { #category : #accessing } LlOneDriveFile class >> urlBase [ - ^ 'https://nrny-my.sharepoint.com/:x:/r/personal' asUrl + ^ 'https://nrny-my.sharepoint.com/' asUrl ] { #category : #accessing } LlOneDriveFile >> downloadUrl [ - ^ self class urlBase withPathSegments: (self file segments copyWithFirst: self owner) + ^ self class urlBase withPathSegments: (self typeCodes / self owner resolvePath: self file) ] { #category : #accessing } @@ -74,6 +78,29 @@ LlOneDriveFile >> printOn: aStream [ print: self url ] +{ #category : #accessing } +LlOneDriveFile >> typeCodes [ + ^ typeCodes + + " + Apparently the first code is related to file type and the second to permissions/visibility + Characters right after the main URL: https://companyname.sharepoint.com change depending on what you are sharing: + +“:f” means Folder sharing +“:w” means Word document sharing +“:x” means Excel document sharing +“:p” means PowerPoint document sharing +“:b” means PDF document sharing (https://sharepointmaven.com/the-anatomy-of-a-sharepoint-url/) + +/:r - indicates a read-only link +/:e - edit link (https://sharepoint.stackexchange.com/a/270230)" +] + +{ #category : #accessing } +LlOneDriveFile >> typeCodes: anObject [ + typeCodes := anObject +] + { #category : #accessing } LlOneDriveFile >> url [