Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
98c7d40f
Commit
98c7d40f
authored
12 years ago
by
Michael Gapczynski
Browse files
Options
Downloads
Patches
Plain Diff
Throw exception in Dropbox and Google Drive storage constructors if parameters are not correct
parent
863d3a43
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/files_external/lib/dropbox.php
+16
-4
16 additions, 4 deletions
apps/files_external/lib/dropbox.php
apps/files_external/lib/google.php
+11
-7
11 additions, 7 deletions
apps/files_external/lib/google.php
with
27 additions
and
11 deletions
apps/files_external/lib/dropbox.php
+
16
−
4
View file @
98c7d40f
...
...
@@ -30,9 +30,13 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
private
static
$tempFiles
=
array
();
public
function
__construct
(
$params
)
{
if
(
isset
(
$params
[
'configured'
])
&&
$params
[
'configured'
]
==
'true'
&&
isset
(
$params
[
'app_key'
])
&&
isset
(
$params
[
'app_secret'
])
&&
isset
(
$params
[
'token'
])
&&
isset
(
$params
[
'token_secret'
]))
{
$oauth
=
new
Dropbox_OAuth_Curl
(
$params
[
'app_key'
],
$params
[
'app_secret'
]);
$oauth
->
setToken
(
$params
[
'token'
],
$params
[
'token_secret'
]);
$this
->
dropbox
=
new
Dropbox_API
(
$oauth
,
'dropbox'
);
}
else
{
throw
new
Exception
(
'Creating OC_Filestorage_Dropbox storage failed'
);
}
}
private
function
getMetaData
(
$path
,
$list
=
false
)
{
...
...
@@ -43,6 +47,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try
{
$response
=
$this
->
dropbox
->
getMetaData
(
$path
);
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
return
false
;
}
if
(
$response
&&
isset
(
$response
[
'contents'
]))
{
...
...
@@ -63,6 +68,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this
->
metaData
[
$path
]
=
$response
;
return
$response
;
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
return
false
;
}
}
...
...
@@ -74,6 +80,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this
->
dropbox
->
createFolder
(
$path
);
return
true
;
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
return
false
;
}
}
...
...
@@ -141,6 +148,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this
->
dropbox
->
delete
(
$path
);
return
true
;
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
return
false
;
}
}
...
...
@@ -150,6 +158,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this
->
dropbox
->
move
(
$path1
,
$path2
);
return
true
;
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
return
false
;
}
}
...
...
@@ -159,6 +168,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this
->
dropbox
->
copy
(
$path1
,
$path2
);
return
true
;
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
return
false
;
}
}
...
...
@@ -173,6 +183,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
file_put_contents
(
$tmpFile
,
$data
);
return
fopen
(
$tmpFile
,
'r'
);
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
return
false
;
}
case
'w'
:
...
...
@@ -211,7 +222,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this
->
dropbox
->
putFile
(
self
::
$tempFiles
[
$tmpFile
],
$handle
);
unlink
(
$tmpFile
);
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
}
}
}
...
...
@@ -230,6 +241,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$info
=
$this
->
dropbox
->
getAccountInfo
();
return
$info
[
'quota_info'
][
'quota'
]
-
$info
[
'quota_info'
][
'normal'
];
}
catch
(
Exception
$exception
)
{
OCP\Util
::
writeLog
(
'files_external'
,
$exception
->
getMessage
(),
OCP\Util
::
ERROR
);
return
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
apps/files_external/lib/google.php
+
11
−
7
View file @
98c7d40f
...
...
@@ -31,13 +31,17 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
private
static
$tempFiles
=
array
();
public
function
__construct
(
$arguments
)
{
$consumer_key
=
isset
(
$arguments
[
'consumer_key'
])
?
$arguments
[
'consumer_key'
]
:
'anonymous'
;
$consumer_secret
=
isset
(
$arguments
[
'consumer_secret'
])
?
$arguments
[
'consumer_secret'
]
:
'anonymous'
;
public
function
__construct
(
$params
)
{
if
(
isset
(
$params
[
'configured'
])
&&
$params
[
'configured'
]
==
'true'
&&
isset
(
$params
[
'token'
])
&&
isset
(
$params
[
'token_secret'
]))
{
$consumer_key
=
isset
(
$params
[
'consumer_key'
])
?
$params
[
'consumer_key'
]
:
'anonymous'
;
$consumer_secret
=
isset
(
$params
[
'consumer_secret'
])
?
$params
[
'consumer_secret'
]
:
'anonymous'
;
$this
->
consumer
=
new
OAuthConsumer
(
$consumer_key
,
$consumer_secret
);
$this
->
oauth_token
=
new
OAuthToken
(
$ar
gument
s
[
'token'
],
$ar
gument
s
[
'token_secret'
]);
$this
->
oauth_token
=
new
OAuthToken
(
$
p
ar
am
s
[
'token'
],
$
p
ar
am
s
[
'token_secret'
]);
$this
->
sig_method
=
new
OAuthSignatureMethod_HMAC_SHA1
();
$this
->
entries
=
array
();
}
else
{
throw
new
Exception
(
'Creating OC_Filestorage_Google storage failed'
);
}
}
private
function
sendRequest
(
$uri
,
$httpMethod
,
$postData
=
null
,
$extraHeaders
=
null
,
$isDownload
=
false
,
$returnHeaders
=
false
,
$isContentXML
=
true
,
$returnHTTPCode
=
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