Class: NVX::SDS::HostedItem
- Inherits:
-
Object
- Object
- NVX::SDS::HostedItem
- Defined in:
- lib/nvx/sds/hosteditem.rb
Overview
Overview
When accessing a file or folder you can share that item publicly. When listing a hosted item this object is returned to represent a file or folder. You can do that by calling session.ListHostedItems.
Usage
This quick example shows how to create
session = Session.new("APP-KEY", "USERNAME", "APP Name", "123123")
root_folder = session.GetRootFolder(1, 500, 0, true)
root_folder.CreateFolders(["testhostfolder"])
root_folder.LoadChildren(1, 500, 0, true)
host_folder = ""
root_folder.folders.each do |folder|
if folder.name == "testhostfolder"
host_folder = folder
break
end
end
host_folder.HostItem
hosted_items = session.ListHostedItems
assert hosted_items.length == 2
host_folder.RemoveHostedItem
session.DeleteFolders([host_folder.path])
Class Method Summary collapse
-
.ListHostedItems(account_login, page_number, page_size) ⇒ Object
Returns the list of currently hosted items based on page number and page size.
Instance Method Summary collapse
-
#GetFileUrl ⇒ Object
Returns the URL for a file that can be used to download the file publicly.
-
#is_file? ⇒ Boolean
Returns if the hosted item is a file or not.
-
#share_path ⇒ Object
Returns the full shared path to the file.
-
#to_s ⇒ Object
Returns a nicely fomatted string based on the share path and if its a file or folder.
Class Method Details
.ListHostedItems(account_login, page_number, page_size) ⇒ Object
Returns the list of currently hosted items based on page number and page size.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/nvx/sds/hosteditem.rb', line 92 def HostedItem.ListHostedItems(account_login, page_number, page_size) params = [APIParam.new("pageNumber", page_number), APIParam.new("pageSize", page_size)] doc = Transport.execute_command_post(APICommand.ListHostedItems, params, account_login); hosted_items = Array.new #if there is any metadata loop through if doc.root.elements["//Response/HostedItem"] doc.root.elements.each("//Response/HostedItem") do |hosted_item| hosted_items << HostedItem.new(account_login, hosted_item) end end return hosted_items end |
Instance Method Details
#GetFileUrl ⇒ Object
Returns the URL for a file that can be used to download the file publicly.
83 84 85 86 87 88 89 |
# File 'lib/nvx/sds/hosteditem.rb', line 83 def GetFileUrl if @is_file raise("Cannot get a download link for a folder.") end Utilities.GetDownloadUrl(@account_login, @share_path, false) end |
#is_file? ⇒ Boolean
Returns if the hosted item is a file or not.
73 74 75 |
# File 'lib/nvx/sds/hosteditem.rb', line 73 def is_file? @is_file end |
#share_path ⇒ Object
Returns the full shared path to the file.
78 79 80 |
# File 'lib/nvx/sds/hosteditem.rb', line 78 def share_path @share_path end |
#to_s ⇒ Object
Returns a nicely fomatted string based on the share path and if its a file or folder.
110 111 112 |
# File 'lib/nvx/sds/hosteditem.rb', line 110 def to_s (@is_file ? "File : " : "Folder : ") + @share_path; end |