mkdir error. permission denied. google api - google-api

I am attempting to use a service account with Google's API to add a calendar event using php. I have this working perfectly on a site already. When i moved it to another site on the same server, i suddenly began to receive the following error messages:
~PHP Warning: mkdir(): Permission denied in Google/Cache/File.php
~Uncaught exception 'Google_Cache_Exception' with message 'Could not create storage directory: in Google/Cache/File.php
The two environments are identical as far as i can tell
~Same server
~Same permissions on all files/folders
~Same credentials
~Both URLS authorized in Google's console
I checked with my server to see if something in the upvoted answer here could be the issue, but was assured that everything was set up correctly.
I've done a lot of searching and reading, but can't imagine what might be causing these errors when everything works perfectly from the other site.
Any help would be much appreciated!

In case anyone comes upon this: I solved this by following the advise given here:
A client error occurred: Could not create storage directory: /tmp/Google_Client/00
specifically, i manually added nested folders (google and cache) inside my tmp directory and then set the path to it for google using this code (from the link above):
$config = new Google_Config();
$config->setClassConfig('Google_Cache_File', array('directory' => '../../tmp/google/cache'));
// Here I set a relative folder to avoid pb on permissions to a folder like /tmp that is not permitted on my mutualised host
$client = new Google_Client($config);

Add this PHP code to your script:
$client = new Google_Client();
$client->setCache(new Google_Cache_File('/path/to/shared/cache'));

In case also that anyone needs to do this. I'm working with Codeigniter and recently moved to osx el capitan on mac from windows 7. My google cache folder had the admin permissions read and write but the error persists: mkdir permission denied, on google/cache/file.php
I looked at my code where I load the google api and added>
$config = new Google_Config();
$config->setClassConfig('Google_Cache_File', array('directory' => 'application/third_party/Google/src/Google/Cache/'));
$client = new Google_Client($config);
So with those line you set your cache folder.
Hope this helps in the future as It helped me.

Related

Download file in Laravel from AWS S3(non public bucket)

I am able to save all my files in the bucket but having difficulties with download.
My code is:
$url = Storage::disk('s3')->temporaryUrl(
$request->file, now()->addMinutes(10)
);
return Storage::disk('s3')->download($url);
Full file path stored in $request->file
Example path: https://bucket_name.privacy_region_info/folder_inside_bucket/cTymyY2gzakfczO3j3H2TtbJX4eeRW4Uj073CZUW
I am getting the fallowing https://prnt.sc/1ip4g77
Did I not understand the purpose od generating temporaryUrl? How can I download files from S3 non public bucket?
BTW I am using Laravel 8 and league/flysystem-aws-s3-v3 1.0.29.
The error message you have shown suggests your user does not have the correct permissions, or that the file does not exist.
If you are sure the file exists, i would suspect a permissions issue.
In AWS IAM, make sure the user has a policy attached to it that grants the correct permissions.
In this case from the comments, i can see the user only has "Write" permissions. You will need explicit "Read" permissions too.

Xamarin Download file to - path access denied

We have an issue with downloading any type of file from our server to our phone.
The problem that we have is that we get an access denied error every time we try to save the said file to phone External Memory.
Access to the path "/storage/emulated/0/Download/Test.txt" is denied.
We have given it all the permissions that we found in:
https://developer.android.com/training/data-storage
for both Documents and other files and Media.
Does anyone have any idea why would this be happening? The 'downloading' the file is not the problem, but the saving part is.
After Android 6.0 , we need to request the permissions in runtime . In xamarin , you could use the plugin PermissionsPlugin to request runtime permission .
Usage
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
bool shouldRequest = await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage);
if(shouldRequest)
{
PermissionStatus status = await CrossPermissions.Current.RequestPermissionAsync<StoragePermission>();
if(status==PermissionStatus.Granted)
{
//do something you want
}
else
{
//...
}
}
For more details about the plugin you could check the github project site .

File Write - Unauthorized Access Exception

Trying to save a file locally from an app running in the iOS 8 Simulator and I'm continually getting access denied exceptions.
In previous apps I've used the following code to get a valid file path:
Environment.GetFolderPath(Environment.SpecialFolder.Personal)
or
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
But I've read that with iOS 8 this has now got to be written as:
NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory,
NSSearchPathDomain.User)[0]
So I'm using the following code to generate a file path for a .txt file and receiving an access denied exception when trying to save with it:
public void SaveMyFile(string content)
{
NSUrl[] urls;
string filePath;
//
urls = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory,
NSSearchPathDomain.User);
filePath = Path.Combine(urls[0].Path, "MyApp", "myFile.txt");
File.WriteAllText(filePath, content);
}
So the file path that it gives me and also denies access to is /Users/Idox/Library/Developer/CoreSimulator/Devices/92498E38-7D50-4081-8A64-83061DC00A86/data/Containers/Data/Application/C35B3E98-C9E3-4ABA-AA7F-CD8419FA0EA5/Documents/MyApp/myFile.txt.
I'm wondering if there's some setting that needs to be toggled to give the app write access to this directory or if the directory itself is invalid.
I've also done a call to Directory.Exists(string path) to check if the directory is there, which it is.
You're missing the Path property on urls[0].Path
filePath = Path.Combine(urls[0].Path, "MyApp", "myFile.txt");
This was fixed in Xamarin.iOS 8.4, so if you're using a recent version of Xamarin you can use Environment.GetFolderPath without problems (which is useful if you want to share code across platforms).

Magento cache_dir is not writable and throws an error

I am new to Mangento. Any operation i do like navigation in the admin panel i am getting the following error.
Can someone tell me where can i find the cache_dir directory in a Magento Installation ?
Also it was working perfectly fine until 3 days. what could have made this error ?
http://pastebin.com/jHcD82wv
The cache folder is by default here:
/var/www/html/var/cache
or here:
/var/www/html/<Magento installation dir>/var/cache
By the way, if you're not sure how to find a folder, you can always go to the root directory and do:
ls -R | grep -i cache
Update:
The name of the variable is cache_dir. It is taken from: app/code/core/Mage/Core/Model/Config/Options.php:
$this->_data['cache_dir'] = $this->_data['var_dir'].DS.'cache';

Zend OSX, and a "." added to context path

I downloaded and unpacked the latest version of Zend Framework, onto OSX (10.6) (am also running webserver with XAMPP, but I added the include_path change to both XAMPP and OSX path, but this is all command line so I dont think the php compiler is using the XAMPP install)
I try to create a project and get the following: (note that i am replacing part of the path with "----" just for the purpose of privacy)
sh-3.2# zf create project
testProject
Fatal error: Uncaught exception
'Zend_Exception' with message 'File "Zend/Tool/Project/Context/Zf/./AbstractClassFile.php" does not exist or class "Zend_Tool_Project_Context_Zf_._AbstractClassFile" was not found in the file' in /Volumes/----/----/z/library/Zend/Loader.php:99 Stack trace:
0 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(88):
Zend_Loader::loadClass('Zend_Tool_Proje...')
1 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(79):
Zend_Tool_Project_Context_Repository->addContextClass('Zend_Tool_Proje...')
2 /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php(87):
Zend_Tool_Project_Context_Repository->addContextsFromDirectory('/Volumes/----/...',
'Zend_Tool_Proje...')
3 /Volumes/----/----/z/library/Zend/Tool/Framework/Provider/Repository.php(187):
Zend_Tool_Project_Provider_Abstract->initialize()
4 /Volumes/----/----/z/library/Zend/Tool/Framework/Client/Abstract.php(128):
Zend_Tool_F in
/Volumes/----/----/z/library/Zend/Loader.php
on line 99 sh-3.2#
Note the period after "Context_Zf_"
I've narrowed it down to this block of code:
File: /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php
public function initialize()
{
// initialize the ZF Contexts (only once per php request)
if (!self::$_isInitialized) {
// load all base contexts ONCE
$contextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Zf/', 'Zend_Tool_Project_Context_Zf_'
);
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Filesystem/', 'Zend_Tool_Project_Context_Filesystem_'
);
// determine if there are project specfic providers ONCE
Specifically "dirname(dirname(FILE))" is echoing as "."
if I wrap the block with an 'if (dirname(dirname(__FILE))!=".") { … } ', then I don't get that error, but I get another:
sh-3.2# zf create project testProject
An Error Has Occurred
Context by name applicationDirectory does not exist in the registry.
Zend Framework Command Line Console
Tool v1.11.3 Details for action
"Create" and provider "Project"
Project
zf create project path name-of-profile file-of-profile
I tested on my Mac and it works fine. Have you tried to restart you xampp server, I don't really know how it works as I use Apache & PHP already installed versions not a "AMP pack". Maybe it's a problem with the php.ini include_path which has not been reloaded.
It's clearly a problem with the path as it don't succeed to build the class name :
"Zend/Tool/Project/Context/Zf/./AbstractClassFile.php"
the dot should not appear here.
Can you share you PATH variable from the terminal and your include_path from your php.ini.
Sadly the solution was to install zend server community edition, and have that take care of everything for me. For anyone else on OSX going this route, check out: http://cmorrell.com/webdev/installing-zend-server-zend-framework-on-os-x-291
includes the steps for enabling CLI support.

Resources