Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/src/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ cp("mylocalfile.bin", io)
io2 = open(AzContainer("foo"; storageaccount="mystorageaccount", session), "mycopyblob.bin")
cp(io, io2)

# get the container (similar to getting the root path of a POSIX filename)
dirname(io)

# remove the blob
rm(io)
```
7 changes: 7 additions & 0 deletions src/AzStorage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ write(io, rand(10))
"""
Base.joinpath(container::AzContainer, name...) = open(container, join(name, '/'), false)

"""
dirname(object::AzObject) -> AzContainer

returns the container/prefix of the `object::AzObject`.
"""
Base.dirname(object::AzObject) = object.container

"""
open(object::AzObject[, mode="w+"]) -> object

Expand Down
13 changes: 13 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,19 @@ end
c = AzContainer(""; storageaccount="", session=session, nthreads=2, nretry=10)
io = joinpath(c, "bar", "baz")
@test isfile(io) == false
rm(c)
end

@testset "Object, dirname" begin
r = uuid4()
c = AzContainer("foo-$r-k", storageaccount=storageaccount, session=session, nthreads=2, nretry=10)
io = robust_joinpath(c, "bar", "baz")
_c = dirname(io)
@test isa(_c, AzContainer)
@test _c.storageaccount == c.storageaccount
@test _c.containername == c.containername
@test _c.prefix == c.prefix
rm(c)
end

@testset "Object, open" begin
Expand Down
Loading