---
title: Upload from a URL
summary: Let BIM.works download a model straight from cloud storage with a pass-through URL, and when to download it yourself instead.
order: 20
languages: [javascript, java, csharp, php]
terms: [node, version, streaming-upload]
see-also: [how-to/models/upload-a-model, how-to/models/list-the-tree, reference/file-types]
---

# Upload from a URL

For a backend whose models live in S3, Azure Blob Storage or another store reachable by URL. Instead of moving the bytes through your server twice, hand the URL to BIM.works and let the repository fetch the file itself. The Java SDK also offers the opposite: download the file to a temporary location and upload it as usual.

## Before you start

- A login with the `model:upload` scope and write rights on the target folder.
- A URL that the **BIM.works server** can use: its host resolves and routes from the server (not only from your machine), and it carries its own authorisation, a pre-signed URL on S3 or a shared access signature on Azure.
- The file name, which usually cannot be read from such a URL, and the file size in bytes, which the storage service may not send in a `Content-Length` header.

## 1. Pass the URL through

```code-group {#pass-through} classic
```java
import java.net.URI;
import java.net.URL;
import nl.bimbase.bimworks.client.UploadModelResponse;
import nl.bimbase.bimworks.client.upload.UploadBuilder;

URL url = URI.create("https://bucket.s3.eu-west-1.amazonaws.com/house.ifc?X-Amz-Signature=...").toURL();
UploadModelResponse response = client.upload.uploadModel(
		new UploadBuilder(folderUuid).urlPassThrough(url, 52_428_800L).filename("house.ifc"));
UUID versionUuid = response.getNewVersionUuid();
```
```csharp
UploadBuilder builder = new UploadBuilder(folderUuid)
    .PassThrough(new Uri("https://bucket.s3.eu-west-1.amazonaws.com/house.ifc?X-Amz-Signature=..."), 52428800L);
builder.filename = "house.ifc";
UploadResponse response = client.Upload.UploadModel(builder).GetUploadResponse();
Guid versionUuid = response.treeNode.GetLastVersion().Uuid;
```
```

```sdk-example
operation: AddModelWithUrl
body: |
  {
    "node_uuid": "<folder uuid>",
    "filename": "house.ifc",
    "url": "https://bucket.s3.eu-west-1.amazonaws.com/house.ifc?X-Amz-Signature=..."
  }
```

The builder methods are `UploadBuilder.urlPassThrough(URL, long)` and `filename` in Java ([[java:nl.bimbase.bimworks.client.apis.UploadApi|UploadApi]]) and `UploadBuilder.PassThrough(Uri, long)` in .NET ([[dotnet:BIM.works_SDK.Upload|Upload]]); PHP calls `ModelApi::addModelWithUrl` ([[page:reference/sdk/php]]). Over HTTP the operation is [[openapi:AddModelWithUrl]]; it needs no size, blocks until the model is checked in and answers with the new version:

```try-it
operation: AddModelWithUrl
method: POST
path: /openapi/model/AddModelWithUrl
body: |
  {
    "node_uuid": "<folder uuid>",
    "filename": "house.ifc",
    "url": "https://bucket.s3.eu-west-1.amazonaws.com/house.ifc?X-Amz-Signature=..."
  }
```

The server waits up to an hour for the download and another for the check-in, but the reverse proxy of a standard installation stops waiting after ten minutes (`proxy_read_timeout 600s`) and answers `504` with `REQUEST_TIMED_OUT` while the server carries on. The model node is created before the download starts, so look it up by its path in the target folder ([[openapi:GetNode]] with `path`): its `tree_node_status` becomes `DONE` once the version is checked in, with the new version in `last_version_uuid`, or `ERROR` when the check-in fails, with the reason in `errors`.

`path` may replace `node_uuid`: the target node's path below the root node of the credential (`/Projects/House`), answered with [[error:NODE_NOT_FOUND]] when nothing is there. Without either the model lands in the root node of the credential. `input_file_type` overrides the type derived from the file name, which is the way to upload from an extension-less URL.

```note
The JavaScript SDK's `upload.uploadFromUrl(url, filename, nodeUuid)` ([[js:@bimworks/jssdk/Upload|Upload]]) is not a pass-through: the browser fetches the URL itself and uploads the bytes, so the URL must be readable from the page (same origin or CORS-enabled), and an HTTP error rejects the call instead of uploading the error page. Use it for files that are already next to your page, not for cloud storage.
```

## 2. Or download first, then upload

When the URL is reachable from your server but not from BIM.works (an internal file server), let the SDK fetch it. Java's `UploadBuilder.url(URL)` downloads to a temporary file and uploads that, with the usual deduplication ([[page:how-to/models/upload-a-model]]); the file passes through your machine and needs disk space for the whole model.

```java {#url}
UploadModelResponse response = client.upload.uploadModel(
		new UploadBuilder(folderUuid).url(URI.create("https://files.internal/house.ifc").toURL()).filename("house.ifc"));
```

## 3. Read the errors

A pass-through fails on the server side, so the errors name what the server saw: [[error:INVALID_URL]] for a URL it cannot parse, [[error:UPLOAD_URL_CANNOT_RESOLVE_DNS]] and [[error:UPLOAD_URL_NO_ROUTE_TO_HOST]] for a host it cannot reach, [[error:UPLOAD_URL_NOT_AUTHORIZED]] when the storage answers 401 or 403 (missing credentials, or a signature that has expired) and [[error:UPLOAD_URL_NOT_FOUND]] when it answers 404. A URL on a private, loopback or link-local address is refused before anything is fetched, [[error:UPLOAD_URL_REFUSED]], unless the instance lists the host in `egress.allowed_private_hosts`. Any other answer is [[error:UNKNOWN_UPLOAD_ERROR]]. A file that parses badly fails like any other upload.

## Check

The reply carries a new version whose `filename` is the name you passed; [[page:how-to/models/list-the-tree]] shows the node in the folder, and a query on the version returns its objects ([[page:how-to/query/run-a-bql-query]]).
