简体   繁体   中英

Issue uploading images/non text files to Rackspace Cloudfiles (MisMatchedChecksumException) via PHP API

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?

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM