Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
f49de343
Commit
f49de343
authored
11 years ago
by
Björn Schießle
Browse files
Options
Downloads
Plain Diff
Merge pull request #5193 from owncloud/fix_5126_2
fix upload to /Shared
parents
20939258
6c45fab0
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/connector/sabre/directory.php
+16
-2
16 additions, 2 deletions
lib/private/connector/sabre/directory.php
lib/private/connector/sabre/file.php
+11
-0
11 additions, 0 deletions
lib/private/connector/sabre/file.php
with
27 additions
and
2 deletions
lib/private/connector/sabre/directory.php
+
16
−
2
View file @
f49de343
...
...
@@ -50,8 +50,22 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public
function
createFile
(
$name
,
$data
=
null
)
{
if
(
!
\OC\Files\Filesystem
::
isCreatable
(
$this
->
path
))
{
throw
new
\Sabre_DAV_Exception_Forbidden
();
// for chunked upload also updating a existing file is a "createFile"
// because we create all the chunks before reasamble them to the existing file.
if
(
isset
(
$_SERVER
[
'HTTP_OC_CHUNKED'
]))
{
// exit if we can't create a new file and we don't updatable existing file
$info
=
OC_FileChunking
::
decodeName
(
$name
);
if
(
!
\OC\Files\Filesystem
::
isCreatable
(
$this
->
path
)
&&
!
\OC\Files\Filesystem
::
isUpdatable
(
$this
->
path
.
'/'
.
$info
[
'name'
]))
{
throw
new
\Sabre_DAV_Exception_Forbidden
();
}
}
else
{
// For non-chunked upload it is enough to check if we can create a new file
if
(
!
\OC\Files\Filesystem
::
isCreatable
(
$this
->
path
))
{
throw
new
\Sabre_DAV_Exception_Forbidden
();
}
}
$path
=
$this
->
path
.
'/'
.
$name
;
...
...
This diff is collapsed.
Click to expand it.
lib/private/connector/sabre/file.php
+
11
−
0
View file @
f49de343
...
...
@@ -45,7 +45,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return string|null
*/
public
function
put
(
$data
)
{
$fs
=
$this
->
getFS
();
if
(
$fs
->
file_exists
(
$this
->
path
)
&&
!
$fs
->
isUpdatable
(
$this
->
path
))
{
throw
new
\Sabre_DAV_Exception_Forbidden
();
...
...
@@ -58,12 +60,14 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
// chunked handling
if
(
isset
(
$_SERVER
[
'HTTP_OC_CHUNKED'
]))
{
list
(
$path
,
$name
)
=
\Sabre_DAV_URLUtil
::
splitPath
(
$this
->
path
);
$info
=
OC_FileChunking
::
decodeName
(
$name
);
if
(
empty
(
$info
))
{
throw
new
Sabre_DAV_Exception_NotImplemented
();
}
$chunk_handler
=
new
OC_FileChunking
(
$info
);
$chunk_handler
->
store
(
$info
[
'index'
],
$data
);
if
(
$chunk_handler
->
isComplete
())
{
...
...
@@ -78,6 +82,13 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
// mark file as partial while uploading (ignored by the scanner)
$partpath
=
$this
->
path
.
'.part'
;
// if file is located in /Shared we write the part file to the users
// root folder because we can't create new files in /shared
// we extend the name with a random number to avoid overwriting a existing file
if
(
dirname
(
$partpath
)
===
'Shared'
)
{
$partpath
=
pathinfo
(
$partpath
,
PATHINFO_FILENAME
)
.
rand
()
.
'.part'
;
}
try
{
$putOkay
=
$fs
->
file_put_contents
(
$partpath
,
$data
);
if
(
$putOkay
===
false
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment