JxBrowser。加载本地资源

时间:2019-04-08 10:41:33

标签: jxbrowser

在JxBrowser中是否可以从类路径或本地文件中引用资源(图像,脚本等)? 尝试了几种方法:

<img src="image.png"/>
<img src="file://image.png"/>
<img src="file://full/path/image.png"/>

这些都不起作用

1 个答案:

答案 0 :(得分:0)

您可以传递以下Chromium开关:

from pyspark.sql import SparkSession

def foreach_batch_function(df, epoch_id):
    df.write\
        .format("com.databricks.spark.redshift") \
        .option("aws_iam_role", my_role) \
        .option("url", my_redshift_url) \
        .option("user", my_redshift_user) \
        .option("password", my_redshift_password) \
        .option("dbtable", my_redshift_schema + "." + my_redshift_table)\
        .option("tempdir", "s3://my/temp/dir") \
        .mode("append")\
        .save()

spark = SparkSession.builder.getOrCreate()

sc = spark.sparkContext

sc._jsc.hadoopConfiguration().set("fs.s3.awsAccessKeyId", my_aws_access_key_id)
sc._jsc.hadoopConfiguration().set("fs.s3.awsSecretAccessKey", my_aws_secret_access_key)

my_schema = spark.read.parquet(my_schema_file_path).schema

df = spark \
    .readStream \
    .schema(my_schema) \
    .option("maxFilesPerTrigger", 100) \
    .parquet(my_source_path)

df.writeStream \
    .trigger(processingTime='30 seconds') \
    .foreachBatch(foreach_batch_function)\
    .option("checkpointLocation", my_checkpoint_location) \
    .start(outputMode="update").awaitTermination()

对于这种方法,这是一个可行的示例:

BrowserPreferences.setChromiumSwitches(        
"--disable-web-security",        
"--allow-file-access-from-files");