classes/Tools/MediaUpload/UploadTool.php
private function importUploadedFile() {
		if(!current_user_can('upload_files')) {
			json_response(["status" => "error", "message" => "Current user can't upload."]);
		}

		$key = $_POST['key'];
		if(empty($key)) {
			json_response(['status' => 'error', 'message' => 'Missing key.']);
		}

		$info = $this->client->info($key);

		$unknownMimes = [
			'application/octet-stream',
			'application/binary',
			'unknown/unknown'
		];

		if(!empty($info->mimeType()) && !in_array($info->mimeType(), $unknownMimes)) {
			if(strpos($info->mimeType(), 'image/') === 0) {
				$result = apply_filters('ilab_cloud_import_from_storage', $info);
				if($result) {
					json_response(['status' => 'success', 'data' => $result]);
				} else {
					json_response(['status' => 'error', 'message' => 'Error importing S3 file into WordPress.']);
				}
			} else {
				json_response(['status' => 'error', 'message' => 'Unknown type.', 'type' => $info->mimeType()]);
			}
		} else {
			json_response(['status' => 'error', 'message' => 'Unknown type.', 'type' => $info->mimeType()]);
		}
	}
private function importUploadedFile() {
		if(!current_user_can('upload_files')) {
			json_response(["status" => "error", "message" => "Current user can't upload."]);
		}

		$key = $_POST['key'];
		if(empty($key)) {
			json_response(['status' => 'error', 'message' => 'Missing key.']);
		}

		$info = $this->client->info($key);

		$unknownMimes = [
			'application/octet-stream',
			'application/binary',
			'unknown/unknown'
		];

		if(!empty($info->mimeType()) && !in_array($info->mimeType(), $unknownMimes)) {
			if(strpos($info->mimeType(), 'image/') === 0) {
				$result = apply_filters('ilab_cloud_import_from_storage', $info);
				if($result) {
					json_response(['status' => 'success', 'data' => $result]);
				} else {
					json_response(['status' => 'error', 'message' => 'Error importing S3 file into WordPress.']);
				}
			} else {
				json_response(['status' => 'error', 'message' => 'Unknown type.', 'type' => $info->mimeType()]);
			}
		} else {
			json_response(['status' => 'error', 'message' => 'Unknown type.', 'type' => $info->mimeType()]);
		}
	}
private function importUploadedFile ( ) { if ( ! current_user_can ( 'upload_files' ) ) { json_response ( [ "status" => "error" , "message" => "Current user can't upload." ] ) ; } $ key = $ _POST [ 'key' ] ; if ( empty ( $ key ) ) { json_response ( [ 'status' => 'error' , 'message' => 'Missing key.' ] ) ; } $ info = $ this -> client -> info ( $ key ) ; $ unknownMimes = [ 'application/octet-stream' , 'application/binary' , 'unknown/unknown' ] ; if ( ! empty ( $ info -> mimeType ( ) ) && ! in_array ( $ info -> mimeType ( ) , $ unknownMimes ) ) { if ( strpos ( $ info -> mimeType ( ) , 'image/' ) === 0 ) { $ result = apply_filters ( 'ilab_cloud_import_from_storage' , $ info ) ; if ( $ result ) { json_response ( [ 'status' => 'success' , 'data' => $ result ] ) ; } else { json_response ( [ 'status' => 'error' , 'message' => 'Error importing S3 file into WordPress.' ] ) ; } } else { json_response ( [ 'status' => 'error' , 'message' => 'Unknown type.' , 'type' => $ info -> mimeType ( ) ] ) ; } } else { json_response ( [ 'status' => 'error' , 'message' => 'Unknown type.' , 'type' => $ info -> mimeType ( ) ] ) ; } }
Called after a file has been uploaded and needs to be imported into the system.
Called after a file has been uploaded and needs to be imported into the system .