@@ 393-401 (lines=9) @@ | ||
390 | return new WP_Error( 'rest_upload_invalid_disposition', __( 'Invalid Content-Disposition supplied. Content-Disposition needs to be formatted as `attachment; filename="image.png"` or similar.' ), array( 'status' => 400 ) ); |
|
391 | } |
|
392 | ||
393 | if ( ! empty( $headers['content_md5'] ) ) { |
|
394 | $content_md5 = array_shift( $headers['content_md5'] ); |
|
395 | $expected = trim( $content_md5 ); |
|
396 | $actual = md5( $data ); |
|
397 | ||
398 | if ( $expected !== $actual ) { |
|
399 | return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected' ), array( 'status' => 412 ) ); |
|
400 | } |
|
401 | } |
|
402 | ||
403 | // Get the content-type |
|
404 | $type = array_shift( $headers['content_type'] ); |
|
@@ 561-568 (lines=8) @@ | ||
558 | } |
|
559 | ||
560 | // Verify hash, if given |
|
561 | if ( ! empty( $headers['content_md5'] ) ) { |
|
562 | $content_md5 = array_shift( $headers['content_md5'] ); |
|
563 | $expected = trim( $content_md5 ); |
|
564 | $actual = md5_file( $files['file']['tmp_name'] ); |
|
565 | if ( $expected !== $actual ) { |
|
566 | return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected' ), array( 'status' => 412 ) ); |
|
567 | } |
|
568 | } |
|
569 | ||
570 | // Pass off to WP to handle the actual upload |
|
571 | $overrides = array( |