I'm using the PHP Google Cloud Storage library (https://github.com/googleapis/google-cloud-php-storage) to upload .msg (outlook message export) files.
However while it works most of the time I'm getting the error below for about 1 in 200 files.
PHP Fatal error: Uncaught Google\Cloud\Core\Exception\BadRequestException: Malformed multipart body. in /home/jamie/import_systems/vendor/google/cloud-core/src/RequestWrapper.php:368
Stack trace:
#0 /home/jamie/import_systems/vendor/google/cloud-core/src/RequestWrapper.php(207): Google\Cloud\Core\RequestWrapper->convertToGoogleException()
#1 /home/jamie/import_systems/vendor/google/cloud-core/src/Upload/MultipartUploader.php(44): Google\Cloud\Core\RequestWrapper->send()
#2 /home/jamie/import_systems/vendor/google/cloud-storage/src/Bucket.php(294): Google\Cloud\Core\Upload\MultipartUploader->upload()
#3 /home/jamie/import_systems/file_uploader.php(47): Google\Cloud\Storage\Bucket->upload()
#4 /home/jamie/import_systems/file_uploader.php(18): UploadAndLinkUpAttachments()
#5 {main}
thrown in /home/jamie/import_systems/vendor/google/cloud-core/src/RequestWrapper.php on line 368
Interestingly I can upload the same files without any issues through the Cloud Storage GUI into the same bucket.
I've checked the library for any encoding options/config but can't see any. I understand its something about the .msg files structure but I would have assumed the library would see that and escape it.
What could the issue be? Or where can I start to debug this?
Related
I have a PHP script that reads files from Cloud Storage. It works fine in local dev. But when it's run in App Engine standard environment, it outputs this error message:
Fatal error: Uncaught Google\Cloud\Core\Exception\ServiceException in /srv/vendor/google/cloud/Core/src/RequestWrapper.php:362
Stack trace:
#0 /srv/vendor/google/cloud/Core/src/RequestWrapper.php(206): Google\Cloud\Core\RequestWrapper->convertToGoogleException(Object(GuzzleHttp\Exception\RequestException))
#1 /srv/vendor/google/cloud/Storage/src/Connection/Rest.php(224): Google\Cloud\Core\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array)
#2 /srv/vendor/google/cloud/Storage/src/StorageObject.php(643): Google\Cloud\Storage\Connection\Rest->downloadObject(Array)
#3 /srv/vendor/google/cloud/Storage/src/StorageObject.php(574): Google\Cloud\Storage\StorageObject->downloadAsStream(Array)
#4 /srv/modules/profile/controllers/getresource.class.php(69): Google\Cloud\Storage\StorageObject->downloadAsString()
This doesn't happen to most of the files. The file causing this issue is about 250KB. I am wondering is there some kind of size limitation with downloadAsString()?
One of the files causing this issue is https://www.justjeans.com.au/wcsstore/JustJeansAuroraStorefrontAssetStore/css/main.css?timestamp=2019070295000
The downloadAsString() method downloads the file using stream, and then casts it to a string before returning it.
Link to the SDK code
There should not be any issues with file sizes unless you are running out of memory in your PHP process.
Is there a file that causes the issue every time? If so, maybe adding that to the question would be a good idea.
I'm trying to push a zip file to iron.io using PHP with cURL but I always get this error.
-My teammates are able to do it, and I do the same, but that exception is generated.
Have someone had the same error or problem? any ideas ? I'm kind of desperate thanks
API POST: 'https://worker-aws-us-east-1.iron.io:443/2/projects/560c4ef63dc302XXXXXXX/codes'
<br />
<b>Fatal error</b>: Uncaught exception 'Http_Exception' with message 'http error: 400 | {"msg":"Code package zip file required if no image specified or using iron/images."}' in /Applications/MAMP/htdocs/www/application/libraries/ironmq/IronCore.class.php:352
Stack trace:
#0 /Applications/MAMP/htdocs/www/application/libraries/ironmq/IronCore.class.php(343): IronCore->reportHttpError(400, '{"msg":"Code pa...')
#1 /Applications/MAMP/htdocs/www/application/libraries/ironmq/IronCore.class.php(305): IronCore->callWithRetries()
#2 /Applications/MAMP/htdocs/www/application/libraries/ironworker/IronWorker.class.php(303): IronCore->apiCall('POST', 'projects/560c4e...', Array, Array)
#3 /Applications/MAMP/htdocs/www/application/libraries/ironworker/CIWorker.php(61): IronWorker->postCode('ironio.php', '/Applications/M...', 'lumiary-stage')
#4 /Applications/MAMP/htdocs/www/application/controllers/admin/tools.php(52): CIWorker->package('lumiary-stage')
#5 [internal function]: Tools->package('lumiary-stage')
#6 /Applications/MAMP/htdocs/www/sy in <b>/Applications/MAMP/htdocs/www/application/libraries/ironmq/IronCore.class.php</b> on line <b>352</b><br />
Your request is malformed (400 status code means Bad Request). You also get an explanation in the error description: Code package zip file required if no image specified or using iron/images.
The final solution was to change my PHP Version. I moved from 5.6 to 5.4 and that did the difference and everything worked as expected.
i have to use google api in my project using php
the project : using google search engine and gathering urls and their source pages
i downloaded google api php client and i followed what ever is written here
https://code.google.com/p/google-api-php-client/
after running i ge this error:
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/plus/v1/people/me/activities/public?key=[REDACTED]: (403) Access Not Configured' in C:\xampp\htdocs\google-api-php-client\src\io\Google_REST.php:66 Stack trace: #0 C:\xampp\htdocs\google-api-php-client\src\io\Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 C:\xampp\htdocs\google-api-php-client\src\service\Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest)) #2 C:\xampp\htdocs\google-api-php-client\src\contrib\Google_PlusService.php(58): Google_ServiceResource->__call('list', Array) #3 C:\xampp\htdocs\googleapitest.php(31): Google_ActivitiesServiceResource->listActivities('me', 'public') #4 {main} thrown in C:\xampp\htdocs\google-api-php-client\src\io\Google_REST.php on line 66
i am completely confused and don't know what to do
That error often means you're not matching your access requirements in the API console - i.e. if you have IP or referrer restrictions configured.
Just remove your developer key and add the scope
'www.googleapis.com/auth/userinfo.email',
'www.googleapis.com/auth/userinfo.profile',
'www.googleapis.com/auth/plus.login',
'www.googleapis.com/auth/plus.me'));
I seem to be getting an error when trying to upload large files into MongoDB..
Fatal error: Uncaught exception 'MongoGridFSException' with message 'could not open file ' in /home/jclark/thundergrid.fusionstrike.com/thundergrid/thundergrid.php:33 Stack trace: #0 /home/jclark/thundergrid.fusionstrike.com/thundergrid/thundergrid.php(33): MongoGridFS->storeUpload('pic', Array) #1 /home/jclark/thundergrid.fusionstrike.com/thundergrid/admin/index.php(7): Admin->upload() #2 {main} Next exception 'MongoGridFSException' with message 'error setting up file: ' in /home/jclark/thundergrid.fusionstrike.com/thundergrid/thundergrid.php:33 Stack trace: #0 /home/jclark/thundergrid.fusionstrike.com/thundergrid/thundergrid.php(0): MongoGridFS->storeUpload() #1 /home/jclark/thundergrid.fusionstrike.com/thundergrid/admin/index.php(7): Admin->upload() #2 {main} thrown in /home/jclark/thundergrid.fusionstrike.com/thundergrid/thundergrid.php on line 33
Is there a reason I'm getting these or...
Many thanks!
If the file is over 2GB/4GB, then this is likely a limitation on how PHP is build on your platform. In most cases, LFS (large file system) is not enabled (and theoretically it's not officially supported by the PHP dev team either). It is also possible that you are using a 32-bit compile of PHP as well, in which case you need a 64-bit build.
I am gelling following error while trying to read file content which is residing in a subfolder rather than a parent folder.
Fatal error: Uncaught exception 'Exception' with message 'Invalid
signature. Expected signature base string:
GET&https%3A%2F%2Fapi-content.dropbox.com%2F1%2Ffiles%2Fdropbox%2FProjects%2FMAC%2520Error.rtf&oauth_consumer_key%3Dbdagb07uu6zq827%26oauth_nonce%3D46d063d5815a0972d63cf72359c0349f%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1324449973%26oauth_token%3D7f2cr9kppqo2hxz%26oauth_version%3D1.0
(Status Code: 403)' in
/Applications/MAMP/htdocs/dbcatalog/BenTheDesigner-Dropbox-88e3876/Dropbox/OAuth/Consumer/Curl.php:133
Stack trace: #0
/Applications/MAMP/htdocs/dbcatalog/BenTheDesigner-Dropbox-88e3876/Dropbox/API.php(109):
Dropbox\OAuth\Consumer\Curl->fetch('GET', 'https://api-con...',
'files/dropbox/P...', Array) #1
/Applications/MAMP/htdocs/dbcatalog/BenTheDesigner-Dropbox-88e3876/check.php(21):
Dropbox\API->getFile('Projects/MAC Er...') #2 {main} thrown in
/Applications/MAMP/htdocs/dbcatalog/BenTheDesigner-Dropbox-88e3876/Dropbox/OAuth/Consumer/Curl.php
on line 133
I am using Ben's Dropbox Library for php
https://github.com/BenTheDesigner/Dropbox
Thanks
If you are looking for a simple PHP-API you can find one here:
https://github.com/hawaiianchimp/Dropbox-PHP-API/
This is the message thats returned when a OAuth request is signed incorrectly. This is likely the fault of the library you're using. At first glance, it looks like it may be encoding the name of your "MAC Error.rtf" file incorrectly. Checkout the PHP SDK dropbox mentions on its website as an alternative and raise this issue with the library's owner.
The code that generates this would help too.