Class: NVX::SDS::HostedItem

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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(, page_number, page_size)
    params = [APIParam.new("pageNumber", page_number),
                APIParam.new("pageSize", page_size)]

    doc = Transport.execute_command_post(APICommand.ListHostedItems, params, );

    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(, hosted_item)
        end
    end
    return hosted_items
end

Instance Method Details

#GetFileUrlObject

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.

Returns:

  • (Boolean)


73
74
75
# File 'lib/nvx/sds/hosteditem.rb', line 73

def is_file?
    @is_file
end

#share_pathObject

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_sObject

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