Definition.load_from_url


#1

Hi all and Happy new Year !

Simple question:
I store component on google storage bucket. I made the file them public and it can be download at “https://storage.cloud.google.com/[bucket_name]/aaa.skp”`

When i’m trying to load them in definitions list wia ruby API. I got an error.

Sketchup.active_model.definitions.load_from_url "https://storage.cloud.google.com/[bucket_name]/aaa.skp"
Error: #<IOError: Invalid component file>
:in load_from_url' <main>:in
SketchUp:1:in `eval’

Previouly I was using S3 bucket whitout trouble, …

Any idea or trick to avoid this ?


#2

It doesn’t seem to work because the URL you passed does not actually return a valid path to the SKP file, it returns another expanded URL with some PHP etc:

Sketchup.active_model.definitions.load_from_url("https://00e9e64bac717fb992817264e9f0c73dfeb0b011e2952fd2b7-apidata.googleusercontent.com/download/storage/v1/b/locabri/o/aaa.skp?qk=AD5uMEsc-iUQCVvS0EZTupiuCWe_x-Lrnoz7p6HBUGzrTI1cbHIFf2dV6MiDDIAsmP1-FOr-UPlXpdOt4jxS3DoofdpE32RolF2RUZ-vkoY90MB9c_E83QeAQD_WpEGh9blVPvFTw_9BlNddnn_OMsIrIwAOjixuYprSjWtGWplnuURUVdQhyVaE9hDJV_1l0_1kYkPE-eLudWJV8HOhN62Wwkp6x_AkL2pVvmMIZ-X9DpVuniOVgYm3gKq3MVf4gbXA1tC0RnIX38XSVWdUJ_A1WWGLZkCQAN79e1kQzF5AttYxXEsdVPV66AYIY9mjBvrqwIF8lgtXoUsqXmK138KDBdbcStGfQuVC4X7H6b87pkScfCyIgLV01vqZzrM1cUWsg0cWCam5JqIUWZvK3j6vqvs6Nmdh3IEN_sNT6lgjALu1LRxmb2-HX9UYORnK3L_029FbmbA-_XGisO9Vg2df9uQuEkbRU_kOi8rTsCvUnMqLJwcLesF_ci-O6MBUy0LNo1uhTCQDJ7Qaf0cElglVW5sb83M8knn3-unSghqzS5BFEqv7uS1UWD_YIR2x25dM8tfujJKrZr1NmCNMnrx6fumj0NHwySaZ3_-MBqCfb3qllJlUeqDhGtTL7zPRihqUAig-n-_Ce5H5CZYcFTeMehDxFCmAb9ZQfs7MJ2s4yVp3X_tBt28wqIH-lmPGli_BucAl6p-TjsBjwtbz7S06tBRpK07vBdCB8N2t9bN41EcBE8uYiNwx4QGXSKk74SuHkLEyjZj6")

Using that new URL loads the SKP from it OK…


#3

Thanks !
Youre right, I finaly use public_url of the objet:
https://[bucket_name].storage.googleapis.com/aaa.skp
instead of
https://storage.cloud.google.com/[bucket_name]/aaa.skp !!