Class: Sharepoint::Folder

Inherits:
Object show all
Includes:
Type
Defined in:
lib/sharepoint-files.rb

Instance Attribute Summary

Attributes inherited from Object

#parent

Attributes inherited from ObjectProperties

#data, #site, #updated_data

Instance Method Summary collapse

Methods included from Type

#initialize

Methods inherited from Object

#copy, #destroy, #guid, #initialize, #reload, #save

Methods inherited from ObjectProperties

#add_properties, #add_property, #available_properties, #initialize

Instance Method Details

#add_file(name, content) ⇒ Object


17
18
19
20
# File 'lib/sharepoint-files.rb', line 17

def add_file name, content
  uri = "#{['uri']}/files/add(overwrite=true,url='#{URI::encode(name.to_s)}')"
  @site.query :post, uri, content
end

#add_folder(name) ⇒ Object


22
23
24
25
26
# File 'lib/sharepoint-files.rb', line 22

def add_folder name
  uri  = "#{['uri']}/folders"
  body = { '__metadata' => { 'type' => 'SP.Folder' }, 'ServerRelativeUrl' => name.to_s }
  @site.query :post, uri, body.to_json
end

#file_from_name(name) ⇒ Object


13
14
15
# File 'lib/sharepoint-files.rb', line 13

def file_from_name name
  @site.query :get, "#{['uri']}/files/getbyurl('#{URI::encode(name.to_s)}')"
end