@@ -4,10 +4,119 @@ All URIs are relative to *https://developers.hostinger.com*
44
55Method | HTTP request | Description
66------------- | ------------- | -------------
7+ [ ** generate_upload_urlv1** ] ( HostingFilesApi.md#generate_upload_urlv1 ) | ** POST** /api/hosting/v1/files/upload-urls | Generate upload URL
78[ ** get_website_file_content_v1** ] ( HostingFilesApi.md#get_website_file_content_v1 ) | ** GET** /api/hosting/v1/accounts/{username}/domains/{domain}/files/content | Get website file content
89[ ** list_website_files_and_directories_v1** ] ( HostingFilesApi.md#list_website_files_and_directories_v1 ) | ** GET** /api/hosting/v1/accounts/{username}/domains/{domain}/files | List website files and directories
910
1011
12+ # ** generate_upload_urlv1**
13+ > HostingV1FilesUploadUrlResource generate_upload_urlv1(hosting_v1_files_generate_upload_url_request)
14+
15+ Generate upload URL
16+
17+ Generate a file browser upload URL with authentication credentials
18+ for uploading files directly to a website's file storage.
19+
20+ Returns ` url ` , ` auth_key ` and ` rest_auth_key ` . Use these to upload a file to the
21+ website's ` public_html ` directory via the TUS resumable upload protocol (TUS 1.0.0).
22+ Send ` X-Auth: {auth_key} ` and ` X-Auth-Rest: {rest_auth_key} ` headers on every request
23+ below.
24+
25+ 1 . Create the upload: ` POST ` to ` {url}/{relative_file_path}?override=true ` with headers
26+ ` upload-length: {file size in bytes} ` and ` upload-offset: 0 ` . Expect ` 201 Created ` .
27+ 2 . Upload the file: send the file bytes to the same location (any TUS 1.0.0 client, or
28+ ` PATCH ` requests with an ` upload-offset ` header tracking progress) until complete.
29+
30+ ` relative_file_path ` is the destination path inside ` public_html ` , e.g. ` app.zip ` .
31+
32+ Instead of a TUS client, plain ` curl ` also works:
33+ ```
34+ FILE=app.zip
35+ SIZE=$(stat -f%z "$FILE") # stat -c%s on Linux
36+
37+ curl -i -X POST "{url}/${FILE}?override=true" \
38+ -H "X-Auth: {auth_key}" \
39+ -H "X-Auth-Rest: {rest_auth_key}" \
40+ -H "Tus-Resumable: 1.0.0" \
41+ -H "Upload-Length: ${SIZE}" \
42+ -H "Upload-Offset: 0"
43+ # -> 201 Created
44+
45+ curl -i -X PATCH "{url}/${FILE}?override=true" \
46+ -H "X-Auth: {auth_key}" \
47+ -H "X-Auth-Rest: {rest_auth_key}" \
48+ -H "Tus-Resumable: 1.0.0" \
49+ -H "Content-Type: application/offset+octet-stream" \
50+ -H "Upload-Offset: 0" \
51+ --data-binary "@${FILE}"
52+ # -> 204 No Content, Upload-Offset response header equals SIZE when done
53+ ```
54+
55+ ### Example
56+
57+ * Bearer Authentication (apiToken):
58+
59+ ``` python
60+ import hostinger_api
61+ from hostinger_api.models.hosting_v1_files_generate_upload_url_request import HostingV1FilesGenerateUploadUrlRequest
62+ from hostinger_api.models.hosting_v1_files_upload_url_resource import HostingV1FilesUploadUrlResource
63+ from hostinger_api.rest import ApiException
64+ from pprint import pprint
65+
66+
67+ # Configure Bearer authorization: apiToken
68+ configuration = hostinger_api.Configuration(
69+ access_token = os.environ[" BEARER_TOKEN" ]
70+ )
71+
72+ # Enter a context with an instance of the API client
73+ with hostinger_api.ApiClient(configuration) as api_client:
74+ # Create an instance of the API class
75+ api_instance = hostinger_api.HostingFilesApi(api_client)
76+ hosting_v1_files_generate_upload_url_request = hostinger_api.HostingV1FilesGenerateUploadUrlRequest() # HostingV1FilesGenerateUploadUrlRequest |
77+
78+ try :
79+ # Generate upload URL
80+ api_response = api_instance.generate_upload_urlv1(hosting_v1_files_generate_upload_url_request)
81+ print (" The response of HostingFilesApi->generate_upload_urlv1:\n " )
82+ pprint(api_response)
83+ except Exception as e:
84+ print (" Exception when calling HostingFilesApi->generate_upload_urlv1: %s \n " % e)
85+ ```
86+
87+
88+
89+ ### Parameters
90+
91+
92+ Name | Type | Description | Notes
93+ ------------- | ------------- | ------------- | -------------
94+ ** hosting_v1_files_generate_upload_url_request** | [ ** HostingV1FilesGenerateUploadUrlRequest** ] ( HostingV1FilesGenerateUploadUrlRequest.md ) | |
95+
96+ ### Return type
97+
98+ [ ** HostingV1FilesUploadUrlResource** ] ( HostingV1FilesUploadUrlResource.md )
99+
100+ ### Authorization
101+
102+ [ apiToken] ( ../README.md#apiToken )
103+
104+ ### HTTP request headers
105+
106+ - ** Content-Type** : application/json
107+ - ** Accept** : application/json
108+
109+ ### HTTP response details
110+
111+ | Status code | Description | Response headers |
112+ | -------------| -------------| ------------------|
113+ ** 200** | Success response | - |
114+ ** 422** | Validation error response | - |
115+ ** 401** | Unauthenticated response | - |
116+ ** 500** | Error response | - |
117+
118+ [[ Back to top]] ( # ) [[ Back to API list]] ( ../README.md#documentation-for-api-endpoints ) [[ Back to Model list]] ( ../README.md#documentation-for-models ) [[ Back to README]] ( ../README.md )
119+
11120# ** get_website_file_content_v1**
12121> HostingV1FilesFileContentResource get_website_file_content_v1(username, domain, path, from_line=from_line, max_lines=max_lines)
13122
0 commit comments