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



19
20
21
22
# File 'lib/sharepoint-files.rb', line 19

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

#add_file_via_streaming(name, file) ⇒ Object



30
31
32
33
34
# File 'lib/sharepoint-files.rb', line 30

def add_file_via_streaming name, file
  add_file name, nil
  spo_file = file_from_name name
  spo_file.upload_file_via_streaming file
end

#add_folder(name) ⇒ Object



24
25
26
27
28
# File 'lib/sharepoint-files.rb', line 24

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



15
16
17
# File 'lib/sharepoint-files.rb', line 15

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