Skip to content

Commit bd4615c

Browse files
julien-langCopilotcarlos-villavicencio-adsk
authored
SG-4373 Improve documentation about local file references (#389)
* Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Carlos Villavicencio <123113322+carlos-villavicencio-adsk@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Carlos Villavicencio <123113322+carlos-villavicencio-adsk@users.noreply.github.com>
1 parent 7b392bd commit bd4615c

2 files changed

Lines changed: 92 additions & 20 deletions

File tree

docs/cookbook/attachments.rst

Lines changed: 86 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ are available:
238238
A dictionary representing which LocalStorage entity is applied for this local file link.
239239

240240
- **url** (:obj:`str`) *read-only*:
241-
A file:// link provided for convenience pointing to the value in the ``local_path``
241+
A file URI (``file://``) path provided for convenience pointing to the value in the ``local_path``
242242

243243
Reading Local File Fields
244244
=========================
@@ -284,40 +284,107 @@ defaults. Any other keys that are provided will be ignored.
284284
Optionally set the mime-type of the associated local file. This is assigned automatically
285285
using a best-guess based on the file extension.
286286

287-
288287
* **name** :obj:`str`:
289288
Optional display name of the local file. This is set to the filename by default.
290289

291290
* **local_path** :obj:`str`:
292-
The full local path to the file. Flow Production Tracking will find the LocalStorage
291+
The full local path to the file. Flow Production Tracking will find the ``LocalStorage``
293292
that has the most specific match to this path and automatically assign that LocalStorage to
294293
the file.
294+
Alternative to ``relative_path``
295+
296+
* **local_storage** :obj:`dict`:
297+
The reference to an existing ``LocalStorage``.
298+
Must contain ``type: LocalStorage`` plus either an ``id`` or a ``name``
299+
300+
* **relative_path** :obj:`str`:
301+
The path to the file relative ``local_storage`` root.
302+
Requires ``local_storage``
303+
Only accepting slash ``/`` separated path. Does not accept Windows path.
304+
Alternative to ``local_path``
305+
306+
Example 1: Using ``local_path``
307+
------------------------------
295308

296309
::
297310

298-
data = {'sg_uploaded_movie': {'local_path': '/Users/kp/Movies/testing/test_movie_002.mov',
299-
'name': 'Better Movie'}
300-
result = sg.update('Version', 123, data)
311+
result = sg.update(
312+
'Version',
313+
123,
314+
{
315+
'sg_uploaded_movie': {
316+
'local_path': '/Users/kp/Movies/testing/test_movie_002.mov',
317+
'name': 'Better Movie',
318+
}
319+
)
301320

302321
Returns::
303322

304-
{'id':123,
305-
'sg_uploaded_movie': { 'content_type': 'video/quicktime',
306-
'link_type': 'local',
307-
'name': 'my_test_movie.mov',
308-
'local_path': '/Users/kp/Movies/testing/test_movie_002.mov'
309-
'local_path_linux': '/home/users/macusers/kp/Movies/testing/test_movie_002.mov'
310-
'local_path_mac': '/Users/kp/Movies/testing/test_movie_002.mov'
311-
'local_path_windows': 'M:\\macusers\kp\Movies\testing\test_movie_002.mov'
312-
'local_storage': {'id': 1,
313-
'name': 'Dailies Directories',
314-
'type': 'LocalStorage'},
315-
'url': 'file:///Users/kp/Movies/testing/test_movie_002.mov'},
316-
'type': 'Version'}]
323+
{
324+
'id':123,
325+
'sg_uploaded_movie': {
326+
'content_type': 'video/quicktime',
327+
'link_type': 'local',
328+
'name': 'my_test_movie.mov',
329+
'local_path': '/Users/kp/Movies/testing/test_movie_002.mov'
330+
'local_path_linux': '/home/users/macusers/kp/Movies/testing/test_movie_002.mov'
331+
'local_path_mac': '/Users/kp/Movies/testing/test_movie_002.mov'
332+
'local_path_windows': 'M:\\macusers\kp\Movies\testing\test_movie_002.mov'
333+
'local_storage': {
334+
'id': 1,
335+
'name': 'Dailies Directories',
336+
'type': 'LocalStorage'
337+
},
338+
'url': 'file:///Users/kp/Movies/testing/test_movie_002.mov'
339+
},
340+
'type': 'Version',
341+
}
317342

318343
The ``content_type`` was assigned a best-guess value based on the file extension. Flow Production Tracking selected
319344
the most appropriate specific LocalStorage match and assigned it to local_storage automatically.
320345

346+
347+
Example 2: Using ``relative_path``
348+
---------------------------------
349+
350+
::
351+
352+
result = sg.update(
353+
'Version',
354+
123,
355+
{
356+
'sg_uploaded_movie': {
357+
'local_storage': {
358+
'type': 'LocalStorage',
359+
'name': 'Dailies Directories',
360+
},
361+
'relative_path': 'testing/test_movie_002.mov',
362+
}
363+
)
364+
365+
Returns::
366+
367+
{
368+
'id':123,
369+
'sg_uploaded_movie': {
370+
'content_type': 'video/quicktime',
371+
'link_type': 'local',
372+
'name': 'my_test_movie.mov',
373+
'local_path': '/Users/kp/Movies/testing/test_movie_002.mov',
374+
'local_path_linux': '/home/users/macusers/kp/Movies/testing/test_movie_002.mov',
375+
'local_path_mac': '/Users/kp/Movies/testing/test_movie_002.mov',
376+
'local_path_windows': 'M:\\macusers\kp\Movies\testing\test_movie_002.mov',
377+
'local_storage': {
378+
'id': 1,
379+
'name': 'Dailies Directories',
380+
'type': 'LocalStorage'
381+
},
382+
'url': 'file:///Users/kp/Movies/testing/test_movie_002.mov'
383+
},
384+
'type': 'Version',
385+
}
386+
387+
321388
Un-setting local file field values
322389
==================================
323390

docs/reference.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,13 @@ Additional keys exist for local file links
803803
'local_path_linux': "string" | None,
804804
'local_path_mac': "string" | None,
805805
'local_path_windows': "string" | None,
806-
'local_storage': {dictionary},
806+
'local_storage': {
807+
'type': 'LocalStorage',
808+
'id': int | None,
809+
'name': "string" | None,
810+
},
807811
'name': "string",
812+
'relative_path': "string" | None
808813
'url': "string",
809814
}
810815
API versions < v3.0.3:

0 commit comments

Comments
 (0)