Issue uploading images/non text files to Rackspace Cloudfiles (MisMatchedChecksumException) via PHP API
Get the solution ↓↓↓I am having an issue uploading to Rackspace Cloudfiles.
I am able to upload anything that is text based (text/html, text/plain etc) but anything else I try fails with the MisMatchedChecksumException which, as I understand it, means the md5_file() on my end doesn't match their computation at their end?
If I don't set the etag (and so this check is not made) the file is uploaded but not correctly, so for example images have the same size but just don't render?
Does anyone have any tips for how to get past this?
Answer
Solution:
The following code works fine for me, can you show a snippet that doesn't work?
$fname = basename('test.jpg');
$md5 = md5_file($fname);
$container = $conn->get_container('my_container');
$o2 = $container->create_object($fname);
$o2->content_type = "image/jpeg";
$o2->set_etag($md5);
$result = $o2->load_from_filename($fname);
assert('!is_null($result)');
assert('$o2->getETag() == $md5');
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: a non well formed numeric value encountered
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.